2022-11-14 14:18:03 +00:00
|
|
|
# Puppeteer Angular Schematic
|
2022-11-09 13:52:10 +00:00
|
|
|
|
2022-11-14 14:18:03 +00:00
|
|
|
Adds Puppeteer-based e2e tests to your Angular project.
|
2022-11-09 13:52:10 +00:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2023-01-13 17:03:21 +00:00
|
|
|
Run the command below in an Angular CLI app directory and follow the prompts.
|
2022-11-09 13:52:10 +00:00
|
|
|
_Note this will add the schematic as a dependency to your project._
|
|
|
|
|
|
|
|
```bash
|
2022-11-14 14:18:03 +00:00
|
|
|
ng add @puppeteer/ng-schematics
|
2022-11-09 13:52:10 +00:00
|
|
|
```
|
|
|
|
|
2023-01-13 17:03:21 +00:00
|
|
|
Or you can use the same command followed by the [options](#options) below.
|
2022-11-14 14:18:03 +00:00
|
|
|
|
|
|
|
Currently, this schematic supports the following test frameworks:
|
|
|
|
|
|
|
|
- **Jasmine** [https://jasmine.github.io/]
|
|
|
|
- **Jest** [https://jestjs.io/]
|
|
|
|
- **Mocha** [https://mochajs.org/]
|
|
|
|
- **Node Test Runner** _(Experimental)_ [https://nodejs.org/api/test.html]
|
|
|
|
|
2022-11-22 13:02:24 +00:00
|
|
|
With the schematics installed you can run E2E tests:
|
2022-11-09 13:52:10 +00:00
|
|
|
|
|
|
|
```bash
|
2022-11-22 13:02:24 +00:00
|
|
|
ng e2e
|
2022-11-09 13:52:10 +00:00
|
|
|
```
|
|
|
|
|
2022-11-23 12:10:03 +00:00
|
|
|
> Note: Command spawns it's own server on the same port `ng serve` does.
|
2022-11-22 13:02:24 +00:00
|
|
|
|
2022-11-14 14:18:03 +00:00
|
|
|
## Options
|
|
|
|
|
|
|
|
When adding schematics to your project you can to provide following options:
|
|
|
|
|
|
|
|
| Option | Description | Value | Required |
|
|
|
|
| -------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | -------- |
|
2022-11-23 12:10:03 +00:00
|
|
|
| `--isDefaultTester` | When true, replaces default `ng e2e` command. | `boolean` | `true` |
|
2022-11-14 14:18:03 +00:00
|
|
|
| `--exportConfig` | When true, creates an empty [Puppeteer configuration](https://pptr.dev/guides/configuration) file. (`.puppeteerrc.cjs`) | `boolean` | `true` |
|
|
|
|
| `--testingFramework` | The testing framework to install along side Puppeteer. | `"jasmine"`, `"jest"`, `"mocha"`, `"node"` | `true` |
|
|
|
|
|
2022-11-23 12:10:03 +00:00
|
|
|
## Contributing
|
|
|
|
|
|
|
|
Check out our [contributing guide](https://pptr.dev/contributing) to get an overview of what you need to develop in the Puppeteer repo.
|
|
|
|
|
2022-11-09 13:52:10 +00:00
|
|
|
### Unit Testing
|
|
|
|
|
|
|
|
The schematics utilize `@angular-devkit/schematics/testing` for verifying correct file creation and `package.json` updates. To execute the test suit:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm run test
|
|
|
|
```
|