Skip to content

Commit 52b123f

Browse files
feat(next-app-router-4000,next-app-router-4001): add Cypress e2e test configuration
- Add Cypress config files for next-app-router-4000 and next-app-router-4001 - Create test directory structure with support files and fixtures - Add basic e2e tests for both apps - Configure proper TypeScript settings for Cypress 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fd303b2 commit 52b123f

File tree

14 files changed

+192
-0
lines changed

14 files changed

+192
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
2+
import { defineConfig } from 'cypress';
3+
4+
export default defineConfig({
5+
projectId: '27e40c91-5ac3-4433-8a87-651d10f51cf6',
6+
e2e: {
7+
...nxE2EPreset(__filename, { cypressDir: 'cypress' }),
8+
baseUrl: 'http://localhost:4000',
9+
},
10+
defaultCommandTimeout: 20000,
11+
retries: {
12+
runMode: 2,
13+
openMode: 1,
14+
},
15+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { getH1 } from '../support/app.po';
2+
3+
describe('next-app-router-4000', () => {
4+
beforeEach(() => cy.visit('/'));
5+
6+
describe('Home page', () => {
7+
it('should display examples heading', () => {
8+
getH1().contains('Examples');
9+
});
10+
11+
it('should have remote button from module federation', () => {
12+
cy.get('button').contains('Button from remote').should('exist');
13+
});
14+
15+
it('should have navigation links', () => {
16+
cy.get('a[href="/layouts"]').should('exist');
17+
cy.get('a[href="/error-handling"]').should('exist');
18+
cy.get('a[href="/loading"]').should('exist');
19+
});
20+
});
21+
22+
describe('Navigation', () => {
23+
it('should navigate to layouts page', () => {
24+
cy.get('a[href="/layouts"]').first().click();
25+
cy.url().should('include', '/layouts');
26+
});
27+
28+
it('should navigate to parallel routes', () => {
29+
cy.get('a[href="/parallel-routes"]').first().click();
30+
cy.url().should('include', '/parallel-routes');
31+
});
32+
});
33+
34+
describe('Module Federation', () => {
35+
it('should load remote button component', () => {
36+
cy.get('button').contains('Button from remote').should('be.visible');
37+
});
38+
});
39+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const getH1 = () => cy.get('h1');
2+
export const getH2 = () => cy.get('h2');
3+
export const getH3 = () => cy.get('h3');
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// ***********************************************
2+
// This example commands.ts shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ***********************************************************
2+
// This example support/e2e.ts is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"sourceMap": false,
5+
"outDir": "../../../dist/out-tsc",
6+
"allowJs": true,
7+
"types": ["cypress", "node"],
8+
"esModuleInterop": true,
9+
"forceConsistentCasingInFileNames": true,
10+
"strict": true,
11+
"skipLibCheck": true
12+
},
13+
"include": ["**/*.ts", "**/*.js", "../cypress.config.ts"]
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
2+
import { defineConfig } from 'cypress';
3+
4+
export default defineConfig({
5+
projectId: '27e40c91-5ac3-4433-8a87-651d10f51cf6',
6+
e2e: {
7+
...nxE2EPreset(__filename, { cypressDir: 'cypress' }),
8+
baseUrl: 'http://localhost:4001',
9+
},
10+
defaultCommandTimeout: 20000,
11+
retries: {
12+
runMode: 2,
13+
openMode: 1,
14+
},
15+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
describe('next-app-router-4001', () => {
2+
beforeEach(() => cy.visit('/'));
3+
4+
describe('Remote component (Button)', () => {
5+
it('should export Button component for module federation', () => {
6+
// This app serves as a remote that exports the Button component
7+
// Testing that the app loads successfully
8+
cy.visit('/');
9+
});
10+
});
11+
12+
describe('Button component functionality', () => {
13+
it('should render default button', () => {
14+
// If there's a test page that renders the button
15+
cy.visit('/');
16+
// Check if the page loads without errors
17+
cy.get('body').should('exist');
18+
});
19+
});
20+
21+
describe('Module Federation Remote', () => {
22+
it('should be accessible as a remote module', () => {
23+
// Verify the app is running and accessible
24+
cy.request('/').its('status').should('eq', 200);
25+
});
26+
});
27+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

0 commit comments

Comments
 (0)