clasp's CLI commands have unit tests that:
- Run the
claspcommand - Compares the expected
stdouttext andstderrcode
- Testing framework: Mocha.js
- Testing CI: Travis CI
- Unit tests run for every Pull Request
- Testing % coverage: Coveralls
- Log in:
clasp login - Rebuild:
sudo npm run build - Set environmental variables:
export TRAVIS_PULL_REQUEST=falseexport SCRIPT_ID=1EwE84eZCSBPcaAiJzCnDjmxMVnLQrDyhSKq1oZY6q-3x4BIDHgQefCnLexport PROJECT_ID=project-id-3961473932623644264
- Test:
npm run test
Note: The build may fail due to API quota limits. To solve this, wait 24 hours and then rebuild Travis.
Travis automatically build and run tests on clasp for.
Since Travis cannot clasp login, a .clasprc.json file is included that was created locally using clasp login.
Use test account
claspcreds@gmail.com. Password is private.
To then encrypt the .clasprc.json file, use these commands using the Travis CLI:
clasp login
cp ~/.clasprc.json ./tests/.clasprc.json
travis encrypt-file ./tests/.clasprc.json --addThis will add the following line to .travis.yml, which decrypts that file:
openssl aes-256-cbc -K $encrypted_0f9bbf7a60f4_key -iv $encrypted_0f9bbf7a60f4_iv -in .clasprc.json.enc -out .clasprc.json -d || true
Now move .clasprc.json.enc to the /tests/ folder:
rm ./tests/.clasprc.json.enc
cp .clasprc.json.enc ./tests/.clasprc.json.enc
rm ./.clasprc.json.enc
And edit the openssl command in .travis.yml file:
- Change the
-infile to./tests/.clasprc.json.enc - Change the
-outfile to.clasprc.json - Add
|| trueto the end of the command
Note: Travis will not decrypt files on a Pull Request from a fork.
There are complicated ways around this. Ideas.
Note: The command ends with
|| trueso Travis doesn't immediately fail on any PR.
This section tracks which clasp commands are tested. Unchecked checkboxes are test cases that still need to be added.
- clasp;
- clasp login';
- clasp login --no-localhost;
- clasp logout;
- clasp create "myTitle"
- clasp create
- clasp list
- clasp clone
- clasp clone
- clasp pull
- clasp push
- echo '// test' >> index.js && clasp push
- clasp open
- clasp deployments
- clasp deploy [version] [description]
- clasp version [description]
- clasp versions
- saveProject
- getScriptURL
- getFileType
- getAPIFileType
- .js, .gs, .ts files
- Ignored files