app-script-mock

1.0.3 • Public • Published

app-script-mock

Mock Google App Script's objects. Make developing and testing GAS simple.

Coverage Status Coverage Status Coverage Status

Install

npm install --save-dev app-script-mock

And before all your tests (you can use mocha's before)

const extendGlobal = require('app-script-mock');
describe('[...]', () => {
	before(() => {
		extendGlobal(global);
	});
});

Why?

This project emerged from another personal project that runs in Google App Script (QuickDrive). With the porpouse of getting your GAS project out of the cloud IDE that Google provides, app-script-mock offers a way to unit test your project.

Example

You want to create a GAS that will read data from a Spreadsheet and then create a Form with questions based on data.

const functionThatCreatesFormsBasedOnSpreadsheet = () => {
	//Your code here that uses FormApp/DriveApp/SpreadsheetApp
	return form.getId();
}
describe('Should create a form with 3 questions based on spreadsheet', () => {
	const createdFormId = functionThatCreatesFormsBasedOnSpreadsheet();
	assert.equal(3, FormApp.openById(createdFormId).getItems().length);
})

Readme

Keywords

none

Package Sidebar

Install

npm i app-script-mock

Weekly Downloads

0

Version

1.0.3

License

APACHE

Last publish

Collaborators

  • matheusmr00