Skip to content

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

License

Notifications You must be signed in to change notification settings

matheusmr13/app-script-mock

Repository files navigation

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);
})

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published