diff --git a/packages/insomnia-smoke-test/README.md b/packages/insomnia-smoke-test/README.md index 43eb387bdb..f53fa69794 100644 --- a/packages/insomnia-smoke-test/README.md +++ b/packages/insomnia-smoke-test/README.md @@ -23,12 +23,13 @@ From the root of this repository: ```shell npm run bootstrap # Install packages and compile inso npm run app-build:smoke # Compile Insomnia +npm run inso-package # Package the Inso CLI binaries ``` You can then run the smoke tests, again from the root: ```shell -npm run test:smoke:cli # Run CLI tests +npm run test:smoke:cli # Run CLI tests npm run test:smoke:build # Run Insomnia tests ``` @@ -205,6 +206,43 @@ In most cases, it will be beneficial to create helper functions under `/modules` Unlike unit tests, the application startup time for a smoke test can sometimes be longer than the test itself. As such, in cases where it is appropriate, **extend** a smoke test with additional steps instead of creating a **new** test. +## Working with fixtures + +### How to update the inso-nedb fixture + +In order to update the inso-nedb fixutre you need to launch Insomnia using the inso-nedb directory. To do this, set the INSOMNIA_DATA_PATH environment variable and launch from the command line. + +#### MacOS + +```bash +INSOMNIA_DATA_PATH=packages/insomnia-smoke-test/fixtures/inso-nedb /Applications/Insomnia.app/Contents/MacOS/Insomnia +``` + +#### Linux + +TODO + +#### Windows + +TODO + +After making your changes, be sure to relaunch the app one more time from the command line, so that Insomnia compacts the database. The .gitignore file will explicity ignore certain database files, to keep the directory size down and avoid prevent data leakage in case you are signed in to the app when launching with this database. + +### How to run inso with the inso-nedb fixture locally? + +Set the `--src packages/insomnia-smoke-test/fixtures/inso-nedb` flag + +```bash +# if installed globally +inso --src ... + +# using the package bin +./packages/insomnia-inso/bin/inso --src ... + +# using a binary +./packages/insomnia-inso/binaries/insomnia-inso --src ... +``` + ## Contributing a smoke test? Smoke tests can potentially be flaky, and one attempt to avoid flaky tests in the default branch is to run the final implementation of a test at least 20 times locally to prove its stability. If a test is unable to achieve this, it is very unlikely to be accepted into the test suite. diff --git a/packages/insomnia-smoke-test/cli/app.test.ts b/packages/insomnia-smoke-test/cli/app.test.ts index 05ccdbc095..f8bd12bb25 100644 --- a/packages/insomnia-smoke-test/cli/app.test.ts +++ b/packages/insomnia-smoke-test/cli/app.test.ts @@ -11,11 +11,19 @@ const binaries = fs.readdirSync(binariesDirectory).map(binary => path.join(binar type NestedArray = (T | T[])[]; -describe.each(compact([npmPackageBinPath, ...binaries]))('inso with %s', binPath => { - if (!binPath) { - fail('The inso executable was not found. Check if it has moved.'); - } +describe('should find binaries', () => { + it('should find the npm package bin', () => { + expect(npmPackageBinPath).not.toBeUndefined(); + }); + it('should find at least one single app binary', () => { + expect(binaries.length).toBeGreaterThanOrEqual(1); + }); +}); + +const srcInsoNedb = ['--src', 'fixtures/inso-nedb']; + +describe.each(compact([npmPackageBinPath, ...binaries]))('inso with %s', binPath => { const inso = (...args: NestedArray) => execa.sync(binPath, flatten(args)); describe('run test', () => { @@ -23,7 +31,7 @@ describe.each(compact([npmPackageBinPath, ...binaries]))('inso with %s', binPath const { failed } = inso( 'run', 'test', - ['--src', 'fixtures/inso-nedb'], + srcInsoNedb, ['--env', 'Dev'], 'Echo Test Suite', ); @@ -31,4 +39,30 @@ describe.each(compact([npmPackageBinPath, ...binaries]))('inso with %s', binPath expect(failed).toBe(false); }); }); + + describe('generate config', () => { + it('should not fail generating config', () => { + const { failed } = inso( + 'generate', + 'config', + srcInsoNedb, + 'Smoke Test API server 1.0.0', + ); + + expect(failed).toBe(false); + }); + }); + + describe('lint spec', () => { + it('should not fail linting spec', () => { + const { failed } = inso( + 'lint', + 'spec', + srcInsoNedb, + 'Smoke Test API server 1.0.0', + ); + + expect(failed).toBe(false); + }); + }); }); diff --git a/packages/insomnia-smoke-test/fixtures/README.md b/packages/insomnia-smoke-test/fixtures/README.md deleted file mode 100644 index 2d9ef33dd5..0000000000 --- a/packages/insomnia-smoke-test/fixtures/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# How to update the inso-nedb fixture - -In order to update the inso-nedb fixutre you need to launch Insomnia using the inso-nedb directory. To do this, set the INSOMNIA_DATA_PATH environment variable and launch from the command line. - -## MacOS - -```bash -INSOMNIA_DATA_PATH=packages/insomnia-smoke-test/fixtures/inso-nedb /Applications/Insomnia.app/Contents/MacOS/Insomnia -``` - -## Linux - -TODO - -## Windows - -TODO - -After making your changes, be sure to relaunch the app one more time from the command line, so that Insomnia compacts the database. The .gitignore file will explicity ignore certain database files, to keep the directory size down and avoid prevent data leakage in case you are signed in to the app when launching with this database.