From 647e566dc09a9ae9e2ef8d11a12addb34b11d63a Mon Sep 17 00:00:00 2001 From: Nick Dower Date: Fri, 18 Feb 2022 20:32:12 +0100 Subject: [PATCH] Add smoke test for create-freesewing-pattern. --- config/scripts.yaml | 2 ++ packages/create-freesewing-pattern/package.json | 5 +++-- .../tests/cli.test.mjs | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 packages/create-freesewing-pattern/tests/cli.test.mjs diff --git a/config/scripts.yaml b/config/scripts.yaml index c524befa4aa..37319e087dc 100644 --- a/config/scripts.yaml +++ b/config/scripts.yaml @@ -22,6 +22,8 @@ create-freesewing-pattern: modulebuild: '!' cibuild_step1: '!' build: '!' + test: 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs' + testci: 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs' css-theme: cibuild_step1: 'npx node-sass --output-style compressed src/theme.scss dist/theme.css' build: 'npx node-sass --output-style compressed src/theme.scss dist/theme.css' diff --git a/packages/create-freesewing-pattern/package.json b/packages/create-freesewing-pattern/package.json index 951e1ba5dc0..ebc429b6442 100644 --- a/packages/create-freesewing-pattern/package.json +++ b/packages/create-freesewing-pattern/package.json @@ -21,11 +21,12 @@ ], "main": "index.js", "scripts": { - "test": "echo \"create-freesewing-pattern: No tests configured. Perhaps you'd like to do this?\" && exit 0", + "test": "BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs", "pubtest": "npm publish --registry http://localhost:6662", "pubforce": "npm publish", "symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -", - "start": "rollup -c -w" + "start": "rollup -c -w", + "testci": "BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs" }, "peerDependencies": {}, "dependencies": { diff --git a/packages/create-freesewing-pattern/tests/cli.test.mjs b/packages/create-freesewing-pattern/tests/cli.test.mjs new file mode 100644 index 00000000000..2990addfa74 --- /dev/null +++ b/packages/create-freesewing-pattern/tests/cli.test.mjs @@ -0,0 +1,17 @@ +import chai from 'chai' +import { spawnSync } from 'child_process' + +describe('CLI help', () => { + it("Should run successfully", () => { + const result = spawnSync('node', ['./lib/cli.js', '-h']) + if (result.status != 0) { + console.log('Command failed: node ./lib/cli.js -h'); + console.log('status: ' + result.status); + console.log('stdout:') + console.log(result.stdout.toString('utf8')); + console.log('stderr:') + console.log(result.stderr.toString('utf8')); + chai.assert.fail(); + } + }) +})