This commit addresses issues #264 and #304, where users were not receiving error messages when script execution failed due to antivirus intervention, particularly with Microsoft Defender. Now, desktop app users will see a detailed error message with guidance on next steps if script saving or execution fails due to antivirus removal. Key changes: - Implement a check to detect failure in file writing, including reading the written file back. This method effectively detects antivirus interventions, as the read operation triggers an antivirus scan, leading to file deletion by the antivirus. - Introduce a specific error message for scenarios where an antivirus intervention is detected.
4.7 KiB
4.7 KiB
Tests
There are different types of tests executed:
Unit and integration tests
- They utilize Vitest.
- Test files are suffixed with
.spec.ts.
Act, arrange, assert
- Tests implement the act, arrange, and assert (AAA) pattern.
- Arrange
- Sets up the test scenario and environment.
- Begins with comment line
// arrange.
- Act
- Executes the actual test.
- Begins with comment line
// act.
- Assert
- Sets an expectation for the test's outcome.
- Begins with comment line
// assert.
Unit tests
- Evaluate individual components in isolation.
- Located in
./tests/unit. - Achieve isolation using stubs where you place:
- Common stubs in
./shared/Stubs, - Component-specific stubs in same folder as test file.
- Common stubs in
- Include Vue component tests, enabled by
@vue/test-utils.
Unit tests naming
- Test suites start with a description of the component or system under test.
- E.g., tests for
Application.tsare contained inApplication.spec.ts.
- E.g., tests for
- Whenever possible,
describeblocks group tests of the same function.- E.g., tests for
run()are insidedescribe('run', () => ...).
- E.g., tests for
Integration tests
- Assess the combined functionality of components.
- They verify that third-party dependencies function as anticipated.
E2E tests
- Examine the live web application's functionality and performance.
- Uses Cypress to run the tests.
Automated checks
These checks validate various qualities like runtime execution, building process, security testing, etc.
- Use various tools and scripts.
- Are automatically executed as GitHub workflows.
Security checks
checks.security.sast: Utilizes CodeQL to conduct Static Analysis Security Testing (SAST) to ensure the secure integrity of the codebase.checks.security.dependencies: Performs audits on third-party dependencies to identify and mitigate potential vulnerabilities, safeguarding the project from exploitable weaknesses.
Tests structure
package.json: Defines test commands and includes tools used in tests.vite.config.ts: Configuresvitestfor unit and integration tests../src/: Contains the code subject to testing../tests/shared/: Contains code shared by different test categories.bootstrap/setup.ts: Initializes unit and integration tests.Assertions/: Contains common assertion functions, prefixed withexpect.
./tests/unit/- Stores unit test code.
- The directory structure mirrors
./src/.- E.g., tests for
./src/application/ApplicationFactory.tsreside in./tests/unit/application/ApplicationFactory.spec.ts.
- E.g., tests for
shared/- Contains shared unit test functionalities.
TestCases/- Shared test cases.
- Functions that calls
it()from Vitest should haveitprefix.
Stubs/: Maintains stubs for component isolation, equipped with basic functionalities and, when necessary, spying or mocking capabilities.
./tests/integration/: Contains integration test files.cypress.config.ts: Cypress (E2E tests) configuration file.cypress-dirs.json: A central definition of directories used by Cypress, designed for reuse across different configurations../tests/e2e/: Base Cypress folder, includes tests with.cy.tsextension.- [
/tsconfig.json]: TypeScript configuration for file Cypress code, improves IDE support, recommended to have by official documentation. - (git ignored)
/videos: Asset folder for videos taken during tests. - (git ignored)
/screenshots: Asset folder for Screenshots taken during tests. /support/e2e.ts: Support file, runs before every single test file./support/interactions/: Contains reusable functions for simulating user interactions, enhancing test readability and maintainability.
- [