- Introduce `fresh-npm-install.sh` to automate clean npm environment
setup.
- Revert workaround 924b326244, resolved
by updating Font Awesome.
- Remove `vue-template-compiler` and `@vue/test-utils` from
dependencies, they're obsolete in 2.7.
- Update anchor references to start with lower case in line with
MD051/link-fragments, introduced by updated `markdownlint`.
- Upgrade cypress to > 10, which includes:
- Change spec extensions from `*.spec.js` to `*.cy.js`.
- Change configuration file from `cypress.json` to
`cypress.config.ts`.
- Remove most configurations from `cypress/plugins/index.js`. These
configurations were initially generated by Vue CLI but obsoleted in
newer cypress versions.
- Lock Typescript version to 4.6.x due to lack of support in
unmaintained Vue CLI TypeScript plugin (see vuejs/vue-cli#7401).
- Use `setWindowOpenHandler` on Electron, replacing deprecated
`new-event` event.
- Document inability to upgrade `typescript-eslint` dependencies because
`@vue/eslint-config-typescript` does not support them. See
vuejs/eslint-config-typescript#60, vuejs/eslint-config-typescript#59,
vuejs/eslint-config-typescript#57.
- Fix `typescript` version to 4.6.X and `tslib` version to 2.4.x,
unit tests exit with a maximum call stack size exceeded error:
```
...
MOCHA Testing...
RUNTIME EXCEPTION Exception occurred while loading your tests
[=========================] 100% (completed)
RangeError: Maximum call stack size exceeded
at RegExp.exec (<anonymous>)
at retrieveSourceMapURL (/project/node_modules/source-map-support/source-map-support.js:174:21)
at Array.<anonymous> (/project/node_modules/source-map-support/source-map-support.js:186:26)
at /project/node_modules/source-map-support/source-map-support.js:85:24
at mapSourcePosition (/project/node_modules/source-map-support/source-map-support.js:216:21)
...
```
Issue has been reported but not fixed, suggested solutions did not
work, see evanw/node-source-map-support#252.
- Update `vue-cli-plugin-electron-builder` to latest alpha version. This
allows upgrading `ts-loader` to latest and using latest
`electron-builder`. Change `main` property value in `package.json` to
`index.js` for successful electron builds (see
nklayman/vue-cli-plugin-electron-builder#188).
82 lines
3.6 KiB
Markdown
82 lines
3.6 KiB
Markdown
# Tests
|
|
|
|
There are different types of tests executed:
|
|
|
|
1. [Unit tests](#unit-tests)
|
|
2. [Integration tests](#integration-tests)
|
|
3. [End-to-end (E2E) tests](#e2e-tests)
|
|
|
|
Common aspects for all tests:
|
|
|
|
- They use [Mocha](https://mochajs.org/) and [Chai](https://www.chaijs.com/).
|
|
- Their files end with `.spec.{ts|js}` suffix.
|
|
|
|
💡 You can use path/module alias `@/tests` in import statements.
|
|
|
|
## Unit tests
|
|
|
|
- Unit tests test each component in isolation.
|
|
- All unit tests goes under [`./tests/unit`](./../tests/unit).
|
|
- They rely on [stubs](./../tests/unit/shared/Stubs) for isolation.
|
|
|
|
### Unit tests structure
|
|
|
|
- [`./src/`](./../src/)
|
|
- Includes source code that unit tests will test.
|
|
- [`./tests/unit/`](./../tests/unit/)
|
|
- Includes test code.
|
|
- Tests follow same folder structure as [`./src/`](./../src).
|
|
- E.g. if system under test lies in [`./src/application/ApplicationFactory.ts`](./../src/application/ApplicationFactory.ts) then its tests would be in test would be at [`./tests/unit/application/ApplicationFactory.spec.ts`](./../tests/unit/application/ApplicationFactory.spec.ts).
|
|
- [`shared/`](./../tests/unit/shared/)
|
|
- Includes common functionality that's shared across unit tests.
|
|
- [`Assertions/`](./../tests/unit/shared/Assertions):
|
|
- Common assertions that extend [Chai Assertion Library](https://www.chaijs.com/).
|
|
- Asserting functions should start with `expect` prefix.
|
|
- [`TestCases/`](./../tests/unit/shared/TestCases/)
|
|
- Shared test cases.
|
|
- Functions that calls `it()` from [Mocha test framework](https://mochajs.org/) should have `it` prefix.
|
|
- E.g. `itEachAbsentCollectionValue()`.
|
|
- [`Stubs/`](./../tests/unit/shared/Stubs)
|
|
- Includes stubs to be able to test components in isolation.
|
|
- Stubs have minimal and dummy behavior to be functional, they may also have spying or mocking functions.
|
|
|
|
### Unit tests naming
|
|
|
|
- Each test suite first describe the system under test.
|
|
- E.g. tests for class `Application.ts` are all inside `Application.spec.ts`.
|
|
- `describe` blocks tests for same function (if applicable).
|
|
- E.g. test for `run()` are inside `describe('run', () => ..)`.
|
|
|
|
### Act, arrange, assert
|
|
|
|
- Tests use act, arrange and assert (AAA) pattern when applicable.
|
|
- **Arrange**
|
|
- Sets up the test case.
|
|
- Starts with comment line `// arrange`.
|
|
- **Act**
|
|
- Executes the actual test.
|
|
- Starts with comment line `// act`.
|
|
- **Assert**
|
|
- Elicit some sort of expectation.
|
|
- Starts with comment line `// assert`.
|
|
|
|
## Integration tests
|
|
|
|
- Tests functionality of a component in combination with others (not isolated).
|
|
- Ensure dependencies to third parties work as expected.
|
|
- Defined in [./tests/integration](./../tests/integration).
|
|
|
|
## E2E tests
|
|
|
|
- Test the functionality and performance of a running application.
|
|
- Vue CLI plugin [`e2e-cypress`](https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-e2e-cypress#readme) configures E2E tests.
|
|
- Test names and folders have logical structure based on tests executed.
|
|
- The structure is following:
|
|
- [`cypress.config.ts`](./../cypress.config.ts): Cypress configuration file.
|
|
- [`./tests/e2e/`](./../tests/e2e/): Base Cypress folder.
|
|
- [`/specs/`](./../tests/e2e/specs/): Test files named with `.spec.js` extension.
|
|
- [`/plugins/index.js`](./../tests/e2e/plugins/index.js): Plugin file executed before loading project.
|
|
- [`/support/index.js`](./../tests/e2e/support/index.js): Support file, runs before every single spec file.
|
|
- *(Ignored)* `/videos`: Asset folder for videos taken during tests.
|
|
- *(Ignored)* `/screenshots`: Asset folder for Screenshots taken during tests.
|