Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8822e26

Browse files
edbzneneajaho
authored andcommitted
test(isr): add basic e2e tests
1 parent 3321b6c commit 8822e26

File tree

6 files changed

+97
-0
lines changed

6 files changed

+97
-0
lines changed

apps/ssr-isr/cypress.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
2+
import { defineConfig } from 'cypress';
3+
4+
export default defineConfig({
5+
e2e: nxE2EPreset(__filename, { cypressDir: 'cypress' }),
6+
});

apps/ssr-isr/cypress/e2e/app.cy.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
describe('RxAngular ISR', () => {
2+
it('should render home page with static data', () => {
3+
cy.visit('/');
4+
5+
cy.get('h1').should('contain', 'Static');
6+
cy.get('p').should('contain', 'Static');
7+
});
8+
9+
it('should render page 1 with dynamic data', () => {
10+
cy.visit('/');
11+
12+
cy.intercept('https://jsonplaceholder.typicode.com/posts/1', {
13+
body: {
14+
title: 'Dynamic Title',
15+
body: 'Dynamic Paragraph',
16+
},
17+
});
18+
19+
cy.get('a').contains('Page 1').click();
20+
21+
cy.get('h2').contains('Dynamic Title');
22+
cy.get('p').contains('Dynamic Paragraph');
23+
});
24+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference types="cypress" />
2+
3+
// ***********************************************
4+
// This example commands.ts shows you how to
5+
// create various custom commands and overwrite
6+
// existing commands.
7+
//
8+
// For more comprehensive examples of custom
9+
// commands please read more here:
10+
// https://on.cypress.io/custom-commands
11+
// ***********************************************
12+
13+
// eslint-disable-next-line @typescript-eslint/no-namespace, @typescript-eslint/no-unused-vars
14+
declare namespace Cypress {
15+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-interface
16+
interface Chainable<Subject> {}
17+
}

apps/ssr-isr/cypress/support/e2e.ts

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.ts using ES2015 syntax:
17+
import './commands';

apps/ssr-isr/cypress/tsconfig.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"outDir": "../../dist/out-tsc",
6+
"module": "commonjs",
7+
"types": ["cypress", "node"],
8+
"sourceMap": false
9+
},
10+
"include": [
11+
"**/*.ts",
12+
"**/*.js",
13+
"../cypress.config.ts",
14+
"../**/*.cy.ts",
15+
"../**/*.cy.tsx",
16+
"../**/*.cy.js",
17+
"../**/*.cy.jsx",
18+
"../**/*.d.ts"
19+
]
20+
}

apps/ssr-isr/project.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@
7373
"options": {
7474
"lintFilePatterns": ["apps/ssr-isr/**/*.ts", "apps/ssr-isr/**/*.html"]
7575
}
76+
},
77+
"e2e": {
78+
"executor": "@nx/cypress:cypress",
79+
"options": {
80+
"cypressConfig": "apps/ssr-isr/cypress.config.ts",
81+
"testingType": "e2e",
82+
"devServerTarget": "ssr-isr:serve"
83+
},
84+
"configurations": {
85+
"production": {
86+
"devServerTarget": "ssr-isr:serve:production"
87+
}
88+
}
7689
}
7790
}
7891
}

0 commit comments

Comments
 (0)