insomnia/packages/insomnia-smoke-test
Filipe Freire ee04eb0c7d
add test for URL being focused on first time user experience (#4385)
* add test for URL being focused on first time user experience

* fix lint

* rm commented code
2022-01-26 12:31:01 +00:00
..
__jest__ Add formatting ESLint rules (#3425) 2021-05-27 14:00:32 -04:00
cli Create single inso executable using pkg (#4049) 2021-10-06 22:01:43 +00:00
fixtures removes insomnia designer migration code (#4404) 2022-01-25 11:14:24 -05:00
playwright removes insomnia designer migration code (#4404) 2022-01-25 11:14:24 -05:00
server fix(import): Importing from the projects view should respect the forc… (#4058) 2021-11-17 10:44:19 +01:00
tests add test for URL being focused on first time user experience (#4385) 2022-01-26 12:31:01 +00:00
.eslintignore Enable ESLint & TS for smoke tests (#3397) 2021-05-19 07:49:48 -04:00
.eslintrc.js adds eslint-config-helpers (#3912) 2021-08-12 18:01:54 -04:00
.gitignore removes insomnia designer migration code (#4404) 2022-01-25 11:14:24 -05:00
.npmrc Chore: replace spectron with playwright (#4305) 2021-12-17 13:05:14 +01:00
jest.config.js Enable ESLint & TS for smoke tests (#3397) 2021-05-19 07:49:48 -04:00
package-lock.json Chore/upgrade-electron-12 (#4232) 2021-12-21 13:03:36 -05:00
package.json can run playwright against latest changes (#4367) 2022-01-19 11:06:28 +00:00
playwright.config.ts Chore: replace spectron with playwright (#4305) 2021-12-17 13:05:14 +01:00
README.md removes insomnia designer migration code (#4404) 2022-01-25 11:14:24 -05:00
tsconfig.build.json removes insomnia designer migration code (#4404) 2022-01-25 11:14:24 -05:00
tsconfig.json Chore: replace spectron with playwright (#4305) 2021-12-17 13:05:14 +01:00

Insomnia Smoke Tests

This project contains the smoke testing suite for Insomnia and Inso.

Tests for the Electron app are written using Playwright while tests for the CLI use execa.

Structure

Folder Purpose
/cli tests for inso
/tests tests for Insomnia
/server Express server used by the tests
/fixtures data used by tests and the server

How to run

There are several ways to run a test but the first step is to bootstrap and build or package the relevant application.

From the root of this repository:

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:

npm run app-start-playwright                    # Run Insomnia tests
PWDEBUG=1 npm run test:smoke:dev                # Write Insomnia tests with the playwrite recorder
DEBUG=pw:browser,pw:api npm run test:smoke:dev  # Run Insomnia tests, with verbose output

Sometimes, you might need to run tests against a packaged application. A packaged application is the final artifact which bundles all of the various resources together, and is created for distribution in the form of a .dmg or .exe, etc. Packaging takes longer to do and is only required for edge cases, so we typically run tests against a build. To run packaged tests, from the root:

npm run app-package:smoke      # Package Insomnia
npm run test:smoke:package     # Run Insomnia tests

Each of the above commands will automatically run the Express server, so you do not need to take any extra steps.

How to write

When writing tests, it is recommended to use the scripts in this project directly (instead of from the root, as per the section above). After building and/or packaging your application under test, it will be available under packages/insomnia-app/{build|dist} and you can begin writing your test.

In order to run CLI tests for development, open two terminal tabs in packages/insomnia-smoke-test:

# In the first tab, serve the Express API
npm run serve

# In the second tab, run your tests
npm run cli                         # Run CLI tests

This will allow you to write and monitor the server separately from each test, speeding up the development cycle.

General guidelines

Data

Individual tests will automatically run against a clean Insomnia data directory to keep data isolated.

Dependencies

A test should not depend on any external services unless absolutely necessary. If a particular endpoint is required (eg. for authentication or a specific content type), implement a new endpoint in /server.

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

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

# 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 ...