clasp
's CLI commands have unit tests that:
- Run the
clasp
command - Compares the expected
stdout
text andstderr
code
- Testing framework: Mocha.js
- Testing CI: Travis CI
- Unit tests run for every Pull Request
- Testing % coverage: Coveralls
- Log in:
clasp login
- Rebuild:
npm run build
- Set environmental variables:
export TRAVIS_PULL_REQUEST=false
export SCRIPT_ID=1EwE84eZCSBPcaAiJzCnDjmxMVnLQrDyhSKq1oZY6q-3x4BIDHgQefCnL
export 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
[email protected]
. Password is private.
To then encrypt the .clasprc.json
file, use these commands using the Travis CLI:
clasp login
cp ~/.clasprc.json ./test/.clasprc.json
travis encrypt-file ./test/.clasprc.json --add
This 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 /test/
folder:
rm ./test/.clasprc.json.enc
cp .clasprc.json.enc ./test/.clasprc.json.enc
rm ./.clasprc.json.enc
And edit the openssl
command in .travis.yml
file:
- Change the
-in
file to./test/.clasprc.json.enc
- Change the
-out
file to.clasprc.json
- Add
|| true
to 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
|| true
so 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 <untitled>
- clasp list
- clasp clone <scriptId>
- 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
- getLocalFileType
- getAPIFileType
- .js, .gs, .ts files
- Ignored files