<%#
 Copyright 2013-2026 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      https://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
<%#
 This is a fragment file, it will be merged into the root template if available.
 EJS fragments will process % delimiter tags in the template and & delimiter tags during the merge process.
-%>
<&_ if (fragment.testingSection) { -&>
#### E2E tests

UI end-to-end tests are powered by [Cypress][]. They're located in [<%= cypressDir %>](<%= cypressDir %>)
and can be run by starting Spring Boot in one terminal (`<%= nodePackageManagerCommand %> run app:start`) and running the tests (`<%= nodePackageManagerCommand %> run e2e`) in a second one.

Before running Cypress tests, it's possible to specify user credentials by overriding the `CYPRESS_E2E_USERNAME` and `CYPRESS_E2E_PASSWORD` environment variables.

```bash
export CYPRESS_E2E_USERNAME="<your-username>"
export CYPRESS_E2E_PASSWORD="<your-password>"
```

See Cypress documentation for setting OS [environment variables](https://docs.cypress.io/app/references/environment-variables#Setting) to learn more.

#### Lighthouse audits

You can execute automated [Lighthouse audits](https://developer.chrome.com/docs/lighthouse/overview) with [cypress-audit](https://github.com/mfrachet/cypress-audit) by running `<%= nodePackageManagerCommand %> run e2e:cypress:audits`.

You should only run the audits when your application is packaged with the production profile.

The Lighthouse report is created in `<%= cypressTemporaryDir %>lhreport.html`.
<%_ if (cypressCoverage) { _%>

### E2E Webapp Code Coverage

When using Cypress, you can generate code coverage report by running your dev server with instrumented code:

<%_ if (cypressCoverageWebpack) { _%>
Build your Angular application with instrumented code:

```bash
<%= nodePackageManagerCommand %> run webapp:instrumenter
```

<%_ } _%>
Start your backend without compiling frontend:

```bash
<%= nodePackageManagerCommand %> run backend:start
```

Start your Cypress end to end testing:

```bash
<%= nodePackageManagerCommand %> run e2e --configuration coverage
```

The coverage report is generated under `<%- temporaryDir %>/cypress-coverage` folder.

<%_ } _%>
<&_ } -&>
<&_ if (fragment.referenceSection) { -&>
- [Cypress](https://www.cypress.io/)
<&_ } -&>
