This page contains information useful for testing of CATcher.
Given below are different commands you can use to run the tests.
| Command | Description |
|---|---|
npm run lint | Runs the linter (TSLint) |
npm run test | Runs the tests |
npm run test -- "--code-coverage" | Runs the tests and generates code coverage report under tests/coverage folder |
Sometimes, it may be useful to create and use your own custom CATcher session for manual testing, instead of using the default session on CATcher-org that is shared among the CATcher developers.
A repository containing the settings for the custom session must be set up for CATcher to store and retrieve the issues properly. The easiest way to do this is to fork the CATcher-org/public_data repository and to edit the settings.json and data.csv files accordingly.
In CATcher, submitting a bug in the Bug Reporting phase will create a GitHub issue in the corresponding repository with the appropriate format and labels. For subsequent phases, the responses are stored as comments of that particular issue, and these comments must be of a certain format for CATcher to parse them correctly.
The custom session will not be present in the default dropdown list on CATcher's startup page, so it can be loaded by clicking on the file icon beside the session dropdown. Following which, submit a file with the .json file extension, where the format is specified below.
Jasmine is a behavior-driven development framework specific for testing JavaScript code. We follow the Jasmine Style Guide loosely for our tests (Link under Resources for Jasmine). One main guideline is that a describe block should be created for each method / scenario under test, and an it block should be created for each property being verified.
Resources:
Because the above Jasmine framework does not test the DOM, we require the Angular TestBed Utility functions to set up component tests for testing HTML / view changes of components in CATcher.
Steps to set up component tests:
TestBed function configureTestingModule with the corresponding component's settingsTestBed function to create the component (fixture) to be testedYou can refer to the AssigneeComponent test under our main repository for more details on how to set up a component test in CATcher.
Resources:
ComponentFixture can be executed using npm run e2e. You should see CATcher launch in an instance of Chromium, with some automated actions occurring on it. Note: Google Chrome needs to be installed on the machine. You can also run e2e tests against Firefox,Chromium,Webkit in headless mode if you run npx playwright test
Alternatively, it is highly recommended that you install Playwright Test for VSCode, which would allow you to run specific tests, utilize the pick locator when writing tests, etc.
Relevant Browsers must be installed prior to running tests (i.e. Chrome, Firefox). You will be prompted by Playwright to install your browsers with this command npx playwright install --with-deps if they are not detected.
E2E tests simulate how an user will interact with our application. However, to avoid hitting the GitHub API in our tests, we currently do not perform E2E tests on the production version of CATcher. Instead, a test version of our application where mock data is used to simulate the GitHub API is used in our E2E tests. Under the hood, Playwright first activates this test version of our server using npm run ng:serve:test before running tests.
To cut down the time running Playwright tests, you can first start the testing version manually using npm run ng:serve:test. Subsequent runs of Playwright will see that a test server is live and run the E2E tests again them. You can also run npm run ng:serve:test to further develop or debug the E2E tests.
E2E Tests are run using Playwright testing framework.
playwright.config.ts file located at the project root to define E2E Testing environments. This includes the list of browsers (or "projects" as they call it), base URL, number of workers etc.Page-Objects Files and Test Files in accordance with the Page Object ModelE2E Tests are run with the following stages:
test architecture
test build configuration located in angular.json under projects.catcher.architect.configurations we build a version of CATcher within a test environment that replaces src/environments/environment.ts with src/environments/environment.test.ts on runtime. This file provides data that allows CATcher to switch into "E2E test" mode.src/environments/environment.test.ts) provides information such as,
test flag that is set to true, so that CATcher switches into "E2E test mode"*-module.ts files with the help of Factories (located in /src/app/core/services/factories) that check the current build environment and make the Service Replacements accordingly.Playwright to run test cases that are located in the /e2e directory.