Skip to content

Commit 004cfbc

Browse files
authored
chore: adding cra test app with e2e and ct testing for cy10 config
1 parent 7a32564 commit 004cfbc

34 files changed

+28679
-15
lines changed

.circleci/config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ workflows:
132132
- new-cypress-config/backend
133133
- new-cypress-config/before-all-visit
134134
- new-cypress-config/before-each-visit
135+
- new-cypress-config/cra-e2e-and-ct
135136
- new-cypress-config/exclude-files
136137
- new-cypress-config/frontend
137138
- new-cypress-config/fullstack
@@ -217,6 +218,7 @@ workflows:
217218
- test-new-cypress-config/backend
218219
- test-new-cypress-config/before-all-visit
219220
- test-new-cypress-config/before-each-visit
221+
- test-new-cypress-config/cra-e2e-and-ct
220222
- test-new-cypress-config/exclude-files
221223
- test-new-cypress-config/frontend
222224
- test-new-cypress-config/fullstack
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# example: create react app with both e2e and component testing examples
2+
3+
This example has both e2e and CT tests, which are run sequentially in the `cy:run` script.
4+
It uses the [@cypress/instrument-cra](https://github.com/cypress-io/instrument-cra) package to instrument the
5+
React code before the tests run.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { defineConfig } from 'cypress'
2+
import '@cypress/instrument-cra'
3+
4+
export default defineConfig({
5+
env: {
6+
codeCoverage: {
7+
exclude: 'cypress/**/*.*'
8+
}
9+
},
10+
e2e: {
11+
setupNodeEvents(on, config) {
12+
require('@cypress/code-coverage/task')(on, config)
13+
return config
14+
}
15+
},
16+
17+
component: {
18+
devServer: {
19+
framework: 'create-react-app',
20+
bundler: 'webpack'
21+
},
22+
setupNodeEvents(on, config) {
23+
require('@cypress/code-coverage/task')(on, config)
24+
return config
25+
}
26+
}
27+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('empty spec', () => {
2+
it('passes', () => {
3+
cy.visit('http://localhost:3000')
4+
})
5+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************
3+
// This example commands.ts shows you how to
4+
// create various custom commands and overwrite
5+
// existing commands.
6+
//
7+
// For more comprehensive examples of custom
8+
// commands please read more here:
9+
// https://on.cypress.io/custom-commands
10+
// ***********************************************
11+
//
12+
//
13+
// -- This is a parent command --
14+
// Cypress.Commands.add('login', (email, password) => { ... })
15+
//
16+
//
17+
// -- This is a child command --
18+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19+
//
20+
//
21+
// -- This is a dual command --
22+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23+
//
24+
//
25+
// -- This will overwrite an existing command --
26+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27+
//
28+
// declare global {
29+
// namespace Cypress {
30+
// interface Chainable {
31+
// login(email: string, password: string): Chainable<void>
32+
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33+
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34+
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35+
// }
36+
// }
37+
// }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title>Components App</title>
8+
</head>
9+
<body>
10+
<div data-cy-root></div>
11+
</body>
12+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// ***********************************************************
2+
// This example support/component.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'
18+
import '@cypress/code-coverage/support'
19+
20+
// Alternatively you can use CommonJS syntax:
21+
// require('./commands')
22+
23+
import { mount } from 'cypress/react'
24+
25+
// Augment the Cypress namespace to include type definitions for
26+
// your custom command.
27+
// Alternatively, can be defined in cypress/support/component.d.ts
28+
// with a <reference path="./component" /> at the top of your spec.
29+
declare global {
30+
namespace Cypress {
31+
interface Chainable {
32+
mount: typeof mount
33+
}
34+
}
35+
}
36+
37+
Cypress.Commands.add('mount', mount)
38+
39+
// Example use:
40+
// cy.mount(<MyComponent />)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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'
18+
import '@cypress/code-coverage/support'
19+
20+
// Alternatively you can use CommonJS syntax:
21+
// require('./commands')

0 commit comments

Comments
 (0)