diff --git a/.gitignore b/.gitignore index 1e9d01e..cbb4c2f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build/ .nyc_output package-lock.json __pycache__ +.coverage diff --git a/package.json b/package.json index b39ba6a..121d9b3 100644 --- a/package.json +++ b/package.json @@ -8,19 +8,16 @@ "build/src" ], "scripts": { - "cover": "nyc --reporter=lcov mocha build/test && nyc report", "docs": "echo no docs 👻", - "lint": "eslint samples/ && npm run check", + "lint": "eslint '**/*.js' && gts check", "test": "nyc mocha build/test", "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", "system-test": "mocha build/system-test --timeout 600000", - "check": "gts check", "clean": "gts clean", "compile": "tsc -p .", - "fix": "gts fix && eslint --fix 'samples/*.js'", + "fix": "gts fix && eslint --fix '**/*.js'", "prepare": "npm run compile", "pretest": "npm run compile", - "posttest": "npm run check", "presystem-test": "npm run compile" }, "repository": "googleapis/google-cloud-kvstore", diff --git a/samples/.eslintrc.yml b/samples/.eslintrc.yml index 282535f..0aa37ac 100644 --- a/samples/.eslintrc.yml +++ b/samples/.eslintrc.yml @@ -1,3 +1,4 @@ --- rules: no-console: off + node/no-missing-require: off diff --git a/samples/package.json b/samples/package.json index 265ebff..75c02b1 100644 --- a/samples/package.json +++ b/samples/package.json @@ -5,16 +5,21 @@ "engines": { "node": ">=8" }, + "files": [ + "*.js" + ], "repository": "googleapis/google-cloud-kvstore", "private": true, "scripts": { - "test": "mocha system-test" + "test": "mocha system-test --timeout 10000" }, "dependencies": { "@google-cloud/datastore": "^2.0.0", "google-cloud-kvstore": "^5.0.0" }, "devDependencies": { + "chai": "^4.2.0", + "execa": "^1.0.0", "mocha": "^5.2.0" } } diff --git a/samples/quickstart.js b/samples/quickstart.js index f4b38ba..ab040ea 100644 --- a/samples/quickstart.js +++ b/samples/quickstart.js @@ -18,7 +18,7 @@ const store = new KVStore(datastore); */ async function set() { await store.set('todos', ['eat', 'sleep', 'repeat']); - console.log('Set some values in the datastore.!'); + console.log('Set some values in the datastore.'); } /** diff --git a/samples/system-test/.eslintrc.yml b/samples/system-test/.eslintrc.yml new file mode 100644 index 0000000..6db2a46 --- /dev/null +++ b/samples/system-test/.eslintrc.yml @@ -0,0 +1,3 @@ +--- +env: + mocha: true diff --git a/samples/system-test/quickstart.test.js b/samples/system-test/quickstart.test.js new file mode 100644 index 0000000..55c29cb --- /dev/null +++ b/samples/system-test/quickstart.test.js @@ -0,0 +1,18 @@ +/** + * Copyright 2018 Google LLC + * + * Distributed under MIT license. + * See file LICENSE for detail or copy at https://opensource.org/licenses/MIT + */ + +const {assert} = require('chai'); +const execa = require('execa'); + +describe('quickstart samples', () => { + it('should run the quickstart', async () => { + const {stdout} = await execa.shell('node quickstart'); + assert.match(stdout, /Set some values/); + assert.match(stdout, /Got todos:/); + assert.match(stdout, /todos deleted/); + }); +}); diff --git a/samples/system-test/test.js b/samples/system-test/test.js deleted file mode 100644 index 9783e75..0000000 --- a/samples/system-test/test.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Distributed under MIT license. - * See file LICENSE for detail or copy at https://opensource.org/licenses/MIT - */ - -console.warn(`no sample tests available 👎`);