Skip to content

Commit

Permalink
Add initial e2e testing with cypress
Browse files Browse the repository at this point in the history
Add e2e tests with cypress using `vue add e2e-cypress`.

Vue CLI does not support creating typescript tests at this moment
(vuejs/vue-cli#1350).
  • Loading branch information
undergroundwires committed Dec 16, 2021
1 parent 9b5e0b0 commit ddd2e70
Show file tree
Hide file tree
Showing 13 changed files with 13,867 additions and 9,179 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ jobs:
-
name: Run integration tests
run: npm run test:integration
-
name: Run e2e tests
if: always() # Run even if previous step fail
run: npm run test:e2e -- --headless
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ dist/
.vs
.vscode
#Electron-builder output
/dist_electron
/dist_electron
# Cypress
/tests/e2e/screenshots
/tests/e2e/videos
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
- Testing
- Run unit tests: `npm run test:unit`
- Run integration tests: `npm run test:integration`
- Run e2e (end-to-end) tests
- Interactive mode with GUI: `npm run test:e2e`
- Headless mode without GUI: `npm run test:e2e -- --headless`
- Lint: `npm run lint`
- **Desktop app**
- Development: `npm run electron:serve`
Expand Down
3 changes: 3 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pluginsFile": "tests/e2e/plugins/index.js"
}
56 changes: 37 additions & 19 deletions docs/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,59 @@
- There are two different types of tests executed:
1. [Unit tests](#unit-tests)
2. [Integration tests](#integration-tests)
3. [End-to-end (E2E) tests](#e2e-tests)
- All tests
- Uses [Mocha](https://mochajs.org/) and [Chai](https://www.chaijs.com/).
- Are written in files that includes `.spec` extension.
- 💡 You can use path/module alias `@/tests` in import statements.

## Unit tests

- Tests each component in isolation
- Defined in [`./tests/unit`](./../tests/unit)
- They follow same folder structure as [`./src`](./../src)
- Tests each component in isolation.
- Defined in [`./tests/unit`](./../tests/unit).
- They follow same folder structure as [`./src`](./../src).

### Naming

- Each test suite first describe the system under test
- E.g. tests for class `Application` is categorized under `Application`
- Tests for specific methods are categorized under method name (if applicable)
- E.g. test for `run()` is categorized under `run`
- Each test suite first describe the system under test.
- E.g. tests for class `Application` is categorized under `Application`.
- Tests for specific methods are categorized under method name (if applicable).
- E.g. test for `run()` is categorized under `run`.

### Act, arrange, assert

- Tests use act, arrange and assert (AAA) pattern when applicable
- Tests use act, arrange and assert (AAA) pattern when applicable.
- **Arrange**
- Should set up the test case
- Starts with comment line `// arrange`
- Should set up the test case.
- Starts with comment line `// arrange`.
- **Act**
- Should cover the main thing to be tested
- Starts with comment line `// act`
- Should cover the main thing to be tested.
- Starts with comment line `// act`.
- **Assert**
- Should elicit some sort of response
- Starts with comment line `// assert`
- Should elicit some sort of response.
- Starts with comment line `// assert`.

### Stubs

- Stubs are defined in [`./tests/stubs`](./../tests/unit/stubs)
- They implement dummy behavior to be functional
- Stubs are defined in [`./tests/stubs`](./../tests/unit/stubs).
- They implement dummy behavior to be functional.

## 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)
- 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.
- E2E tests are configured by vue plugin [`e2e-cypress`](https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-e2e-cypress#readme) for Vue CLI.
- Names and folders are structured logically based on tests.
- The structure is following:
- [`cypress.json`](./../cypress.json): Cypress configuration file.
- [`./tests/e2e/`](./../tests/e2e/): Base Cypress folder.
- [`/specs/`](./../tests/e2e/specs/): Test files, test are named with `.spec.js` extension.
- [`/plugins/index.js`](./../tests/e2e/plugins/index.js): Plugin file executed before project is loaded.
- [`/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.
2 changes: 1 addition & 1 deletion img/architecture/gitops.drawio

Large diffs are not rendered by default.

Binary file modified img/architecture/gitops.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ddd2e70

Please sign in to comment.