E2E Testing Patterns
The Goal
End to end (E2E) testing is one of the most undervalued disciplines that an organization can commit to.
There is does not exist a better way to validate the desired outcome of a feature at scale over and over than with E2E testing.
We are going to show how to use Cypress to create automated tests for your application.
Time permitting, we will show how we can add in cucumber to change everything.
Our goal is to write a number of automated tests for our application.
The Code
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
webServerCommands: {
default: 'nx run challenges:serve:development',
production: 'nx run challenges:serve:production',
},
ciWebServerCommand: 'nx run challenges:serve-static',
}),
baseUrl: 'http://localhost:4202',
},
});
<mat-card-title data-test="list-title">
Challenges
</mat-card-title>
export const getTitle = () => cy.get('[data-test="list-title"]');
import { getGreeting, getTitle } from '../support/app.po';
describe('challenges-e2e', () => {
beforeEach(() => cy.visit('/'));
it('should display the title', () => {
getTitle().contains(/Challenges/);
});
});