Skip to content

Commit

Permalink
chore: adding cra test app with e2e and ct testing for cy10 config
Browse files Browse the repository at this point in the history
  • Loading branch information
elylucas authored Jun 10, 2022
1 parent 7a32564 commit 004cfbc
Show file tree
Hide file tree
Showing 34 changed files with 28,679 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ workflows:
- new-cypress-config/backend
- new-cypress-config/before-all-visit
- new-cypress-config/before-each-visit
- new-cypress-config/cra-e2e-and-ct
- new-cypress-config/exclude-files
- new-cypress-config/frontend
- new-cypress-config/fullstack
Expand Down Expand Up @@ -217,6 +218,7 @@ workflows:
- test-new-cypress-config/backend
- test-new-cypress-config/before-all-visit
- test-new-cypress-config/before-each-visit
- test-new-cypress-config/cra-e2e-and-ct
- test-new-cypress-config/exclude-files
- test-new-cypress-config/frontend
- test-new-cypress-config/fullstack
Expand Down
23 changes: 23 additions & 0 deletions test-apps/new-cypress-config/cra-e2e-and-ct/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
5 changes: 5 additions & 0 deletions test-apps/new-cypress-config/cra-e2e-and-ct/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# example: create react app with both e2e and component testing examples

This example has both e2e and CT tests, which are run sequentially in the `cy:run` script.
It uses the [@cypress/instrument-cra](https://github.com/cypress-io/instrument-cra) package to instrument the
React code before the tests run.
27 changes: 27 additions & 0 deletions test-apps/new-cypress-config/cra-e2e-and-ct/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { defineConfig } from 'cypress'
import '@cypress/instrument-cra'

export default defineConfig({
env: {
codeCoverage: {
exclude: 'cypress/**/*.*'
}
},
e2e: {
setupNodeEvents(on, config) {
require('@cypress/code-coverage/task')(on, config)
return config
}
},

component: {
devServer: {
framework: 'create-react-app',
bundler: 'webpack'
},
setupNodeEvents(on, config) {
require('@cypress/code-coverage/task')(on, config)
return config
}
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('empty spec', () => {
it('passes', () => {
cy.visit('http://localhost:3000')
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts 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
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('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) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// ***********************************************************
// This example support/component.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import '@cypress/code-coverage/support'

// Alternatively you can use CommonJS syntax:
// require('./commands')

import { mount } from 'cypress/react'

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount
}
}
}

Cypress.Commands.add('mount', mount)

// Example use:
// cy.mount(<MyComponent />)
21 changes: 21 additions & 0 deletions test-apps/new-cypress-config/cra-e2e-and-ct/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import '@cypress/code-coverage/support'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading

0 comments on commit 004cfbc

Please sign in to comment.