Skip to content

Commit

Permalink
test: basic setup for cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphclue committed Feb 28, 2024
1 parent 8fbf057 commit 6e38738
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 40 deletions.
9 changes: 6 additions & 3 deletions apps/frontend-e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import {defineConfig} from 'cypress';
import {nxE2EPreset} from '@nx/cypress/plugins/cypress-preset';

export default defineConfig({
e2e: nxE2EPreset(__dirname),
e2e: {
...nxE2EPreset(__dirname),
baseUrl: 'http://localhost:4200',
},
});
13 changes: 4 additions & 9 deletions apps/frontend-e2e/src/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { getGreeting } from '../support/app.po';

describe('web', () => {
beforeEach(() => cy.visit('/'));

it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('my-email@something.com', 'myPassword');
beforeEach(() => cy.visit('/dashboard'));

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains('Welcome web');
it('should display the dashboard', () => {
cy.get('app-navbar').should('be.visible');
cy.get('app-dashboard').should('be.visible');
});
});
28 changes: 0 additions & 28 deletions apps/frontend-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

0 comments on commit 6e38738

Please sign in to comment.