Merge branch 'develop' into 7.0-release

This commit is contained in:
Jennifer Shehane
2021-02-23 20:06:29 -05:00
committed by GitHub
134 changed files with 2203 additions and 46130 deletions

1
.gitignore vendored
View File

@@ -38,6 +38,7 @@ packages/server/test/support/fixtures/server/libs
# from npm/react
/npm/react/bin/*
/npm/react/cypress/videos
/npm/react/.babel-cache
# from runner-ct
/packages/runner-ct/cypress/screenshots

View File

@@ -689,7 +689,7 @@ jobs:
cli-visual-tests:
<<: *defaults
parallelism: 1
parallelism: 8
steps:
- attach_workspace:
at: ~/
@@ -1080,55 +1080,29 @@ jobs:
working_directory: npm/vue
- store-npm-logs
npm-react:
<<: *defaults
steps:
- attach_workspace:
at: ~/
- check-conditional-ci
- run:
name: Build
command: yarn workspace @cypress/react build
- run:
name: Run tests
command: yarn workspace @cypress/react test
- store-npm-logs
- persist_to_workspace:
root: ~/
paths: cypress/npm/react
npm-react-e2e-example:
<<: *defaults
description: Run react component testing end-to-end examples
parameters:
executor:
description: Executor name to use
type: executor
default: cy-doc
path:
description: relative to npm/react path of example
type: string
parallelism: 9
steps:
- attach_workspace:
at: ~/
- check-conditional-ci
- restore_cache:
name: Restore Cache
keys:
- yarn-packages-{{ checksum "npm/react/<<parameters.path>>/yarn.lock" }}
name: Restore yarn cache
key: v{{ .Environment.CACHE_VERSION }}-{{ arch }}-npm-react-babel-cache
- run:
name: Install Dependencies
command: yarn install --frozen-lockfile
working_directory: npm/react/<<parameters.path>>
- save_cache:
name: Save Cache
key: yarn-packages-{{ checksum "npm/react/<<parameters.path>>/yarn.lock" }}
paths:
- ~/.cache
name: Build
command: yarn workspace @cypress/react build
- run:
name: Run e2e example tests
command: yarn test
working_directory: npm/react/<<parameters.path>>
name: Run tests
command: yarn test-ci
working_directory: npm/react
- store_test_results:
path: npm/react/test_results
- store_artifacts:
path: npm/react/test_results
- store-npm-logs
npm-eslint-plugin-dev:
<<: *defaults
@@ -1757,79 +1731,9 @@ linux-workflow: &linux-workflow
- npm-react:
requires:
- build
# Run tests for end-to-end react component tests examples
- npm-react-e2e-example:
name: npm-react-axe
path: examples/a11y
requires:
- npm-react
- npm-react-e2e-example:
name: npm-react-next
path: examples/nextjs
requires:
- npm-react
- npm-react-e2e-example:
name: npm-react-cra
path: examples/react-scripts
requires:
- npm-react
- npm-react-e2e-example:
name: npm-react-cra-folder
path: examples/react-scripts-folder
requires:
- npm-react
- npm-react-e2e-example:
name: npm-react-rollup
path: examples/rollup
requires:
- npm-react
- npm-react-e2e-example:
name: npm-react-sass-ts
path: examples/sass-and-ts
requires:
- npm-react
- npm-react-e2e-example:
name: npm-react-snapshots
path: examples/snapshots
requires:
- npm-react
- npm-react-e2e-example:
name: npm-react-tailwind
path: examples/tailwind
requires:
- npm-react
# Requires Applitools key in the env
# - npm-react-e2e-example:
# name: React + Applitools component testing
# path: examples/visual-testing-with-applitools
# requires:
# - npm-react
- npm-react-e2e-example:
name: npm-react-percy
path: examples/visual-testing-with-percy
requires:
- npm-react
# Requires Happo api key in the env vars
# - npm-react-e2e-example:
# name: React + Happo component testing
# path: examples/visual-testing-with-happo
# requires:
# - npm-react
- npm-react-e2e-example:
name: npm-react-webpack-file
path: examples/webpack-file
requires:
- npm-react
- npm-react-e2e-example:
name: npm-react-webpack-options
path: examples/webpack-options
requires:
- npm-react
- npm-eslint-plugin-dev:
requires:
- build
- npm-release:
requires:
- build

View File

@@ -5127,11 +5127,7 @@ declare namespace Cypress {
interface DevServerOptions {
specs: Spec[]
config: {
supportFile?: string
projectRoot: string
webpackDevServerPublicPathRoute: string
},
config: ResolvedConfigOptions & RuntimeConfigOptions,
devServerEvents: NodeJS.EventEmitter,
}

View File

@@ -1,7 +0,0 @@
{
"watch-ignore": [
"node_modules"
],
"require": "ts-node/register",
"exit": true
}

View File

@@ -307,6 +307,14 @@ If your React and React DOM libraries are installed in non-standard paths (think
## Code coverage
In order to use code coverage you can follow the instructions from [docs](https://github.com/cypress-io/code-coverage). In most of cases you need to install 2 dependencies:
```
npm i @cypress/code-coverage babel-plugin-istanbul
yarn add @cypress/code-coverage babel-plugin-istanbul
```
If you are using [plugins/cra-v3](plugins/cra-v3) it instruments the code on the fly using `babel-plugin-istanbul` and generates report using dependency [cypress-io/code-coverage](https://github.com/cypress-io/code-coverage) (included). If you want to disable code coverage instrumentation and reporting, use `--env coverage=false` or `CYPRESS_coverage=false` or set in your `cypress.json` file
```json

View File

@@ -5,10 +5,7 @@
"projectId": "z9dxah",
"testFiles": "**/*spec.{js,jsx,ts,tsx}",
"env": {
"reactDevtools": true,
"cypress-react-selector": {
"root": "#cypress-root"
}
"reactDevtools": true
},
"ignoreTestFiles": [
"**/__snapshots__/*",

View File

@@ -2,9 +2,9 @@ import * as React from 'react'
import { LazyComponent } from './LazyComponent'
import { mount } from '@cypress/react'
// NOTE: It doesn't work because of chunk splitting issue with webpack
describe.skip('React.lazy component with <Suspense />', () => {
describe('React.lazy component with <Suspense />', () => {
it('renders and retries till component is loaded', () => {
cy.viewport(1000, 1000)
mount(<LazyComponent />)
cy.contains('loading...')
cy.contains('Your dog is')

View File

@@ -23,7 +23,7 @@ it('Todo - should create snapshot', () => {
// expect(tree).toMatchSnapshot();
// entire test area
cy.get('#cypress-root')
cy.get('#__cy_root')
.invoke('html')
.then(pretty)
.should(

View File

@@ -16,7 +16,7 @@ describe('Renderless component', () => {
const onMoved = cy.stub()
mount(<MouseMovement onMoved={onMoved} />)
cy.get('#cypress-root').should('be.empty')
cy.get('#__cy_root').should('be.empty')
cy.document()
.trigger('mousemove')
.then(() => {

View File

@@ -1,6 +1,5 @@
import React from 'react'
import { unmountComponentAtNode } from 'react-dom'
import { mount } from '@cypress/react'
import { mount, unmount } from '@cypress/react'
import LoadingIndicator from './LoadingIndicator'
// compare these tests to Jest + Enzyme tests in
@@ -74,17 +73,9 @@ describe('LoadingIndicator', () => {
)
cy.tick(2010)
cy.get('#cypress-root').then(($el) => {
unmountComponentAtNode($el[0])
})
unmount()
cy.get('@clearTimeout').should('have.been.calledOnce')
})
})
afterEach(() => {
cy.get('#cypress-root').then(($el) => {
unmountComponentAtNode($el[0])
})
})
})

View File

@@ -2,7 +2,6 @@
import Card from './card-without-effect.jsx'
import React from 'react'
import { mount, unmount } from '@cypress/react'
import { unmountComponentAtNode } from 'react-dom'
it('should select null after timing out', () => {
const onSelect = cy.stub()
@@ -29,9 +28,7 @@ it('should cleanup on being removed', () => {
expect(onSelect).to.not.have.been.called
})
cy.get('#cypress-root').then(($el) => {
unmountComponentAtNode($el[0])
})
unmount()
cy.tick(5000).then(() => {
expect(onSelect).to.not.have.been.called

View File

@@ -14,7 +14,7 @@ const Hello = ({ children }) => {
describe('mount in before hook', () => {
// let's mount the component once
// and then run multiple tests against it
before(() => {
beforeEach(() => {
mount(
<Hello>
<div className="inside">Inner div</div>

View File

@@ -7,7 +7,7 @@ import pretty from 'pretty'
it('says hello world', () => {
mount(<Hello name="world" />)
cy.contains('Hello, world!').should('be.visible')
cy.get('#cypress-root')
cy.get('#__cy_root')
.invoke('html')
.then(pretty)
.should('equal', '<h1>Hello, world!</h1>')

View File

@@ -1,4 +1,6 @@
// @ts-check
const { startDevServer } = require('@cypress/webpack-dev-server')
const path = require('path')
const babelConfig = require('../../babel.config.js')
/** @type import("webpack").Configuration */
@@ -17,7 +19,7 @@ const webpackConfig = {
{
test: /\.(js|jsx|mjs|ts|tsx)$/,
loader: 'babel-loader',
options: babelConfig,
options: { ...babelConfig, cacheDirectory: path.resolve(__dirname, '..', '..', '.babel-cache') },
},
{
test: /\.modules\.css$/i,
@@ -59,7 +61,7 @@ const webpackConfig = {
* @type Cypress.PluginConfig
*/
module.exports = (on, config) => {
on('dev-server:start', (options) => startDevServer({ options, webpackConfig }))
on('dev-server:start', (options) => startDevServer({ options, webpackConfig, disableLazyCompilation: false }))
return config
}

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*spec.js",
"viewportWidth": 500,

View File

@@ -1,2 +1 @@
require('@cypress/react/support')
require('cypress-axe')

View File

@@ -8,6 +8,7 @@
},
"devDependencies": {
"@cypress/react": "file:../../dist",
"cypress-axe": "0.8.1"
"cypress-axe": "0.8.1",
"cypress-circleci-reporter": "0.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"testFiles": "**/*.spec.{js,jsx}",
"viewportWidth": 500,
"viewportHeight": 800,

View File

@@ -1,2 +1 @@
import '@cypress/react/support'
import '@cypress/code-coverage/support'

View File

@@ -18,6 +18,7 @@
"@next/mdx": "^9.5.3",
"@zeit/next-sass": "^1.0.1",
"check-code-coverage": "1.9.2",
"cypress-circleci-reporter": "0.2.0",
"next": "^9.5.3"
},
"license": "MIT"

View File

@@ -1109,6 +1109,35 @@
resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-9.5.3.tgz#a14fb6489d412b201b98aa44716fb8727ca4c6ae"
integrity sha512-W3VKOqbg+4Kw+k6M/SODf+WIzwcx60nAemGV1nNPa/yrDtAS2YcJfqiswrJ3+2nJHzqefAFWn4XOfM0fy8ww2Q==
"@oozcitak/dom@1.15.8":
version "1.15.8"
resolved "https://registry.yarnpkg.com/@oozcitak/dom/-/dom-1.15.8.tgz#0c0c7bb54cfdaadc07fd637913e706101721d15d"
integrity sha512-MoOnLBNsF+ok0HjpAvxYxR4piUhRDCEWK0ot3upwOOHYudJd30j6M+LNcE8RKpwfnclAX9T66nXXzkytd29XSw==
dependencies:
"@oozcitak/infra" "1.0.8"
"@oozcitak/url" "1.0.4"
"@oozcitak/util" "8.3.8"
"@oozcitak/infra@1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@oozcitak/infra/-/infra-1.0.8.tgz#b0b089421f7d0f6878687608301fbaba837a7d17"
integrity sha512-JRAUc9VR6IGHOL7OGF+yrvs0LO8SlqGnPAMqyzOuFZPSZSXI7Xf2O9+awQPSMXgIWGtgUf/dA6Hs6X6ySEaWTg==
dependencies:
"@oozcitak/util" "8.3.8"
"@oozcitak/url@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@oozcitak/url/-/url-1.0.4.tgz#ca8b1c876319cf5a648dfa1123600a6aa5cda6ba"
integrity sha512-kDcD8y+y3FCSOvnBI6HJgl00viO/nGbQoCINmQ0h98OhnGITrWR3bOGfwYCthgcrV8AnTJz8MzslTQbC3SOAmw==
dependencies:
"@oozcitak/infra" "1.0.8"
"@oozcitak/util" "8.3.8"
"@oozcitak/util@8.3.8":
version "8.3.8"
resolved "https://registry.yarnpkg.com/@oozcitak/util/-/util-8.3.8.tgz#10f65fe1891fd8cde4957360835e78fd1936bfdd"
integrity sha512-T8TbSnGsxo6TDBJx/Sgv/BlVJL3tshxZP7Aq5R1mSnM5OcHY2dQaxLMu2+E8u3gN0MLOzdjurqN4ZRVuzQycOQ==
"@sindresorhus/is@^2.1.0":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-2.1.1.tgz#ceff6a28a5b4867c2dd4a1ba513de278ccbe8bb1"
@@ -1167,6 +1196,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.5.tgz#fecad41c041cae7f2404ad4b2d0742fdb628b305"
integrity sha512-jVFzDV6NTbrLMxm4xDSIW/gKnk8rQLF9wAzLWIOg+5nU6ACrIMndeBdXci0FGtqJbP9tQvm6V39eshc96TO2wQ==
"@types/node@14.6.2":
version "14.6.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.2.tgz#264b44c5a28dfa80198fc2f7b6d3c8a054b9491f"
integrity sha512-onlIwbaeqvZyniGPfdw/TEhKIh79pz66L1q06WUQqJLnAb6wbjvOtepLYTGHTqzdXgBYIE3ZdmqHDGsRsbBz7A==
"@types/parse5@^5.0.0":
version "5.0.3"
resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-5.0.3.tgz#e7b5aebbac150f8b5fdd4a46e7f0bd8e65e19109"
@@ -2411,6 +2445,14 @@ cyclist@^1.0.1:
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=
cypress-circleci-reporter@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/cypress-circleci-reporter/-/cypress-circleci-reporter-0.2.0.tgz#a3e1571694f4e21649a6af4d508e68948d23622d"
integrity sha512-uhqcJwvtKJ7Bw3RHVBTqUH9GP2L6jq+qLp/+/Jh3/OSe5Af6H7RxIARhvawsvbPrg9lMWdW/jCezjeUcXrl9uA==
dependencies:
strip-ansi "^6.0.0"
xmlbuilder2 "^2.1.1"
d@1, d@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a"
@@ -3641,7 +3683,7 @@ js-tokens@^3.0.2:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=
js-yaml@^3.13.1:
js-yaml@3.14.0, js-yaml@^3.13.1:
version "3.14.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482"
integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==
@@ -5434,7 +5476,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"
strip-ansi@6.0.0:
strip-ansi@6.0.0, strip-ansi@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
@@ -5983,6 +6025,17 @@ wrappy@1:
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
xmlbuilder2@^2.1.1:
version "2.4.0"
resolved "https://registry.yarnpkg.com/xmlbuilder2/-/xmlbuilder2-2.4.0.tgz#fb6c5171bef1bcb984c88cfef5210e17b7b841cd"
integrity sha512-KrOVUGD65xTQ7ZA+GMQGdBSpe1Ufu5ylCQSYVk6QostySDkxPmAQ0WWIu7dR3JjLfVbF22RFQX7KyrZ6VTLcQg==
dependencies:
"@oozcitak/dom" "1.15.8"
"@oozcitak/infra" "1.0.8"
"@oozcitak/util" "8.3.8"
"@types/node" "14.6.2"
js-yaml "3.14.0"
xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*cy-spec.js",
"viewportWidth": 500,

View File

@@ -1,2 +1 @@
require('@cypress/react/support')
require('@cypress/code-coverage/support')

View File

@@ -12,6 +12,7 @@
"devDependencies": {
"@cypress/react": "file:../../dist",
"check-code-coverage": "1.9.2",
"cypress-circleci-reporter": "0.2.0",
"react-scripts": "3.4.1"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"testFiles": "**/*cy-spec.js",
"viewportWidth": 500,
"viewportHeight": 800,

View File

@@ -1,2 +1 @@
require('@cypress/react/support')
require('@cypress/code-coverage/support')

View File

@@ -12,6 +12,7 @@
"devDependencies": {
"@cypress/react": "file:../../dist",
"check-code-coverage": "1.9.2",
"cypress-circleci-reporter": "0.2.0",
"react-scripts": "3.4.3"
},
"browserslist": {

View File

@@ -6,8 +6,7 @@ const ingredients = ['bacon', 'tomato', 'mozzarella', 'pineapples']
describe('RemotePizza', () => {
it('download ingredients from internets (network mock)', () => {
cy.server()
cy.route('https://httpbin.org/anything*', { args: { ingredients } }).as(
cy.intercept('https://httpbin.org/anything*', { args: { ingredients } }).as(
'pizza',
)

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"testFiles": "**/*spec.{ts,tsx}",
"experimentalComponentTesting": true,
"experimentalFetchPolyfill": true,

View File

@@ -16,6 +16,7 @@
"@rollup/plugin-babel": "5.2.1",
"@rollup/plugin-commonjs": "15.1.0",
"@rollup/plugin-node-resolve": "9.0.0",
"@rollup/plugin-replace": "2.3.3"
"@rollup/plugin-replace": "2.3.3",
"cypress-circleci-reporter": "0.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*spec.*",
"viewportWidth": 500,

View File

@@ -1 +0,0 @@
require('@cypress/react/support')

View File

@@ -13,6 +13,7 @@
},
"devDependencies": {
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0",
"sass": "1.32.0"
}
}

View File

@@ -5,11 +5,45 @@
"@cypress/react@file:../../dist":
version "0.0.0"
"@oozcitak/dom@1.15.8":
version "1.15.8"
resolved "https://registry.yarnpkg.com/@oozcitak/dom/-/dom-1.15.8.tgz#0c0c7bb54cfdaadc07fd637913e706101721d15d"
integrity sha512-MoOnLBNsF+ok0HjpAvxYxR4piUhRDCEWK0ot3upwOOHYudJd30j6M+LNcE8RKpwfnclAX9T66nXXzkytd29XSw==
dependencies:
"@oozcitak/infra" "1.0.8"
"@oozcitak/url" "1.0.4"
"@oozcitak/util" "8.3.8"
"@oozcitak/infra@1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@oozcitak/infra/-/infra-1.0.8.tgz#b0b089421f7d0f6878687608301fbaba837a7d17"
integrity sha512-JRAUc9VR6IGHOL7OGF+yrvs0LO8SlqGnPAMqyzOuFZPSZSXI7Xf2O9+awQPSMXgIWGtgUf/dA6Hs6X6ySEaWTg==
dependencies:
"@oozcitak/util" "8.3.8"
"@oozcitak/url@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@oozcitak/url/-/url-1.0.4.tgz#ca8b1c876319cf5a648dfa1123600a6aa5cda6ba"
integrity sha512-kDcD8y+y3FCSOvnBI6HJgl00viO/nGbQoCINmQ0h98OhnGITrWR3bOGfwYCthgcrV8AnTJz8MzslTQbC3SOAmw==
dependencies:
"@oozcitak/infra" "1.0.8"
"@oozcitak/util" "8.3.8"
"@oozcitak/util@8.3.8":
version "8.3.8"
resolved "https://registry.yarnpkg.com/@oozcitak/util/-/util-8.3.8.tgz#10f65fe1891fd8cde4957360835e78fd1936bfdd"
integrity sha512-T8TbSnGsxo6TDBJx/Sgv/BlVJL3tshxZP7Aq5R1mSnM5OcHY2dQaxLMu2+E8u3gN0MLOzdjurqN4ZRVuzQycOQ==
"@types/json-schema@^7.0.5":
version "7.0.6"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0"
integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==
"@types/node@14.6.2":
version "14.6.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.2.tgz#264b44c5a28dfa80198fc2f7b6d3c8a054b9491f"
integrity sha512-onlIwbaeqvZyniGPfdw/TEhKIh79pz66L1q06WUQqJLnAb6wbjvOtepLYTGHTqzdXgBYIE3ZdmqHDGsRsbBz7A==
ajv-keywords@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
@@ -25,6 +59,11 @@ ajv@^6.12.4:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
ansi-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
anymatch@~3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142"
@@ -33,6 +72,13 @@ anymatch@~3.1.1:
normalize-path "^3.0.0"
picomatch "^2.0.4"
argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
dependencies:
sprintf-js "~1.0.2"
big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
@@ -65,11 +111,24 @@ braces@~3.0.2:
optionalDependencies:
fsevents "~2.1.2"
cypress-circleci-reporter@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/cypress-circleci-reporter/-/cypress-circleci-reporter-0.2.0.tgz#a3e1571694f4e21649a6af4d508e68948d23622d"
integrity sha512-uhqcJwvtKJ7Bw3RHVBTqUH9GP2L6jq+qLp/+/Jh3/OSe5Af6H7RxIARhvawsvbPrg9lMWdW/jCezjeUcXrl9uA==
dependencies:
strip-ansi "^6.0.0"
xmlbuilder2 "^2.1.1"
emojis-list@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78"
integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==
esprima@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
fast-deep-equal@^3.1.1:
version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
@@ -123,6 +182,14 @@ is-number@^7.0.0:
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
js-yaml@3.14.0:
version "3.14.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482"
integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
json-schema-traverse@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
@@ -213,6 +280,18 @@ semver@^7.3.2:
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
strip-ansi@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
dependencies:
ansi-regex "^5.0.0"
to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
@@ -226,3 +305,14 @@ uri-js@^4.2.2:
integrity sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g==
dependencies:
punycode "^2.1.0"
xmlbuilder2@^2.1.1:
version "2.4.0"
resolved "https://registry.yarnpkg.com/xmlbuilder2/-/xmlbuilder2-2.4.0.tgz#fb6c5171bef1bcb984c88cfef5210e17b7b841cd"
integrity sha512-KrOVUGD65xTQ7ZA+GMQGdBSpe1Ufu5ylCQSYVk6QostySDkxPmAQ0WWIu7dR3JjLfVbF22RFQX7KyrZ6VTLcQg==
dependencies:
"@oozcitak/dom" "1.15.8"
"@oozcitak/infra" "1.0.8"
"@oozcitak/util" "8.3.8"
"@types/node" "14.6.2"
js-yaml "3.14.0"

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*-spec.js",
"viewportWidth": 500,

View File

@@ -1,3 +1,2 @@
require('@cypress/react/support')
require('@cypress/code-coverage/support')
require('cypress-plugin-snapshots/commands')

View File

@@ -9,6 +9,7 @@
"test": "node ../../../../scripts/cypress run"
},
"devDependencies": {
"@cypress/react": "file:../../dist"
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*cy-spec.js",
"viewportWidth": 500,

View File

@@ -1,2 +1 @@
require('@cypress/react/support')
require('@cypress/code-coverage/support')

View File

@@ -11,6 +11,7 @@
},
"devDependencies": {
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0",
"tailwindcss": "1.4.6"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*spec.tsx",
"viewportWidth": 500,

View File

@@ -1 +0,0 @@
require('@cypress/react/dist/hooks')

View File

@@ -12,6 +12,7 @@
"@babel/preset-env": "7.4.5",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "7.10.4",
"@cypress/react": "file:../../dist"
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*spec.js",
"viewportWidth": 500,

View File

@@ -1 +0,0 @@
require('@cypress/react/dist/hooks')

View File

@@ -11,6 +11,7 @@
"@babel/plugin-proposal-class-properties": "7.4.4",
"@babel/preset-env": "7.4.5",
"@babel/preset-react": "7.0.0",
"@cypress/react": "file:../../dist"
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*cy-spec.js",
"viewportWidth": 1000,

View File

@@ -1,5 +1,4 @@
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command'
require('@cypress/react/support')
require('@cypress/code-coverage/support')
addMatchImageSnapshotCommand()

View File

@@ -29,6 +29,7 @@
"extends": "react-app"
},
"devDependencies": {
"@cypress/react": "file:../../dist"
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,11 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*spec.js",
"viewportWidth": 1000,
"viewportHeight": 1000,
"experimentalComponentTesting": true,
"componentFolder": "src",
"video": false,
"env": {
"coverage": false
}

View File

@@ -8,6 +8,7 @@
},
"devDependencies": {
"@applitools/eyes-cypress": "3.14.0",
"@cypress/react": "file:../../dist"
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"testFiles": "**/*cy-spec.js",
"viewportWidth": 400,
"viewportHeight": 700,

View File

@@ -1,3 +1,2 @@
require('@cypress/react/support')
require('@cypress/code-coverage/support')
require('happo-cypress')

View File

@@ -9,6 +9,7 @@
},
"devDependencies": {
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0",
"happo-cypress": "1.9.1",
"happo.io": "5.6.1"
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*cy-spec.js",
"viewportWidth": 500,

View File

@@ -7,6 +7,7 @@
"test": "node ../../../../scripts/cypress run"
},
"devDependencies": {
"@cypress/react": "file:../../dist"
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0"
}
}

View File

@@ -0,0 +1,96 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@cypress/react@file:../../dist":
version "0.0.0"
"@oozcitak/dom@1.15.8":
version "1.15.8"
resolved "https://registry.yarnpkg.com/@oozcitak/dom/-/dom-1.15.8.tgz#0c0c7bb54cfdaadc07fd637913e706101721d15d"
integrity sha512-MoOnLBNsF+ok0HjpAvxYxR4piUhRDCEWK0ot3upwOOHYudJd30j6M+LNcE8RKpwfnclAX9T66nXXzkytd29XSw==
dependencies:
"@oozcitak/infra" "1.0.8"
"@oozcitak/url" "1.0.4"
"@oozcitak/util" "8.3.8"
"@oozcitak/infra@1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@oozcitak/infra/-/infra-1.0.8.tgz#b0b089421f7d0f6878687608301fbaba837a7d17"
integrity sha512-JRAUc9VR6IGHOL7OGF+yrvs0LO8SlqGnPAMqyzOuFZPSZSXI7Xf2O9+awQPSMXgIWGtgUf/dA6Hs6X6ySEaWTg==
dependencies:
"@oozcitak/util" "8.3.8"
"@oozcitak/url@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@oozcitak/url/-/url-1.0.4.tgz#ca8b1c876319cf5a648dfa1123600a6aa5cda6ba"
integrity sha512-kDcD8y+y3FCSOvnBI6HJgl00viO/nGbQoCINmQ0h98OhnGITrWR3bOGfwYCthgcrV8AnTJz8MzslTQbC3SOAmw==
dependencies:
"@oozcitak/infra" "1.0.8"
"@oozcitak/util" "8.3.8"
"@oozcitak/util@8.3.8":
version "8.3.8"
resolved "https://registry.yarnpkg.com/@oozcitak/util/-/util-8.3.8.tgz#10f65fe1891fd8cde4957360835e78fd1936bfdd"
integrity sha512-T8TbSnGsxo6TDBJx/Sgv/BlVJL3tshxZP7Aq5R1mSnM5OcHY2dQaxLMu2+E8u3gN0MLOzdjurqN4ZRVuzQycOQ==
"@types/node@14.6.2":
version "14.6.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.2.tgz#264b44c5a28dfa80198fc2f7b6d3c8a054b9491f"
integrity sha512-onlIwbaeqvZyniGPfdw/TEhKIh79pz66L1q06WUQqJLnAb6wbjvOtepLYTGHTqzdXgBYIE3ZdmqHDGsRsbBz7A==
ansi-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
dependencies:
sprintf-js "~1.0.2"
cypress-circleci-reporter@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/cypress-circleci-reporter/-/cypress-circleci-reporter-0.2.0.tgz#a3e1571694f4e21649a6af4d508e68948d23622d"
integrity sha512-uhqcJwvtKJ7Bw3RHVBTqUH9GP2L6jq+qLp/+/Jh3/OSe5Af6H7RxIARhvawsvbPrg9lMWdW/jCezjeUcXrl9uA==
dependencies:
strip-ansi "^6.0.0"
xmlbuilder2 "^2.1.1"
esprima@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
js-yaml@3.14.0:
version "3.14.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482"
integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
strip-ansi@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
dependencies:
ansi-regex "^5.0.0"
xmlbuilder2@^2.1.1:
version "2.4.0"
resolved "https://registry.yarnpkg.com/xmlbuilder2/-/xmlbuilder2-2.4.0.tgz#fb6c5171bef1bcb984c88cfef5210e17b7b841cd"
integrity sha512-KrOVUGD65xTQ7ZA+GMQGdBSpe1Ufu5ylCQSYVk6QostySDkxPmAQ0WWIu7dR3JjLfVbF22RFQX7KyrZ6VTLcQg==
dependencies:
"@oozcitak/dom" "1.15.8"
"@oozcitak/infra" "1.0.8"
"@oozcitak/util" "8.3.8"
"@types/node" "14.6.2"
js-yaml "3.14.0"

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*cy-spec.js",
"viewportWidth": 500,

View File

@@ -1,3 +1,2 @@
require('@cypress/react/dist/hooks')
// if we need code coverage, need to include its custom support hook
require('@cypress/code-coverage/support')

View File

@@ -9,6 +9,7 @@
"test": "node ../../../../scripts/cypress run"
},
"devDependencies": {
"@cypress/react": "file:../../dist"
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"video": false,
"fixturesFolder": false,
"testFiles": "**/*cy-spec.js",
"viewportWidth": 500,

View File

@@ -1,3 +1,2 @@
require('@cypress/react/dist/hooks')
// if we need code coverage, need to include its custom support hook
require('@cypress/code-coverage/support')

View File

@@ -9,6 +9,7 @@
"test": "node ../../../../scripts/cypress run"
},
"devDependencies": {
"@cypress/react": "file:../../dist"
"@cypress/react": "file:../../dist",
"cypress-circleci-reporter": "0.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +0,0 @@
module.exports = {
preset: 'ts-jest',
testRegex: '(\\.|/)test\\.[jt]s$',
testEnvironment: 'node',
testPathIgnorePatterns: ['node_modules', 'examples'],
globals: {
'ts-jest': {
tsConfig: 'tsconfig.test.json',
},
},
}

View File

@@ -12,30 +12,26 @@
"cy:run:debug": "NODE_OPTIONS=--max-http-header-size=1048576 node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}",
"pretest": "yarn transpile",
"test": "yarn cy:run",
"test-ci": "node run-tests.js",
"transpile": "tsc",
"watch": "yarn build --watch --watch.exclude ./dist/**/*"
},
"dependencies": {
"@babel/plugin-transform-modules-commonjs": "7.12.1",
"@cypress/code-coverage": "3.8.6",
"@cypress/webpack-preprocessor": "0.0.0-development",
"babel-plugin-istanbul": "6.0.0",
"debug": "4.3.2",
"find-up": "5.0.0",
"find-webpack": "2.2.1",
"mime-types": "2.1.26",
"semver": "7.3.2",
"unfetch": "4.1.0"
"find-webpack": "2.2.1"
},
"devDependencies": {
"@babel/core": "7.4.5",
"@babel/plugin-proposal-class-properties": "7.4.4",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-transform-modules-commonjs": "7.12.1",
"@babel/preset-env": "7.4.5",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "7.10.4",
"@bahmutov/cy-api": "1.4.2",
"@bahmutov/cy-rollup": "2.0.0",
"@cypress/code-coverage": "3.8.6",
"@cypress/webpack-dev-server": "0.0.0-development",
"@date-io/date-fns": "1",
"@emotion/babel-preset-css-prop": "10.0.27",
@@ -58,12 +54,14 @@
"autoprefixer": "9.7.6",
"axios": "0.18.1",
"babel-loader": "8.0.6",
"babel-plugin-istanbul": "6.0.0",
"babel-plugin-module-resolver": "4.0.0",
"bootstrap": "4.4.1",
"check-code-coverage": "1.9.2",
"common-tags": "1.8.0",
"css-loader": "2.1.1",
"cypress": "0.0.0-development",
"cypress-circleci-reporter": "0.2.0",
"cypress-expect": "2.0.0",
"cypress-image-snapshot": "3.1.1",
"cypress-plugin-snapshots": "1.4.4",
@@ -105,6 +103,7 @@
"peerDependencies": {
"@babel/core": "^=7.x",
"@babel/preset-env": "^=7.x",
"@cypress/webpack-dev-server": "*",
"@types/react": "^16.9.16 || ^17.0.0",
"babel-loader": "^=8.x",
"cypress": "*",
@@ -143,6 +142,9 @@
"@babel/preset-env": {
"optional": true
},
"@cypress/webpack-dev-server": {
"optional": true
},
"@types/react": {
"optional": true
},

View File

@@ -1,7 +1,6 @@
const filePreprocessor = require('./file-preprocessor')
module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)
on('file:preprocessor', filePreprocessor(config))
// IMPORTANT to return the config object

View File

@@ -1,7 +1,6 @@
const filePreprocessor = require('./file-preprocessor')
module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)
on('file:preprocessor', filePreprocessor(config))
// IMPORTANT to return the config object

View File

@@ -7,8 +7,6 @@ const { getTranspileFolders } = require('../utils/get-transpile-folders')
const { addImageRedirect } = require('../utils/add-image-redirect')
module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)
const webpackFilename = config.env && config.env.webpackFilename
if (!webpackFilename) {

View File

@@ -1,7 +1,6 @@
const filePreprocessor = require('./file-preprocessor')
module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)
on('file:preprocessor', filePreprocessor(config))
// IMPORTANT to return the config object

View File

@@ -1,7 +1,6 @@
const filePreprocessor = require('../cra-v3/file-preprocessor')
module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)
on('file:preprocessor', filePreprocessor(config))
// IMPORTANT to return the config object

59
npm/react/run-tests.js Normal file
View File

@@ -0,0 +1,59 @@
const execa = require('execa')
const { chdir } = require('process')
const path = require('path')
const testResultsDestination = path.resolve(__dirname, 'test_results')
const REACT_PROJECTS_FOR_CI = [
'', // root project
'/examples/nextjs',
'/examples/react-scripts',
'/examples/webpack-file',
'/examples/react-scripts-folder',
'/examples/using-babel-typescript',
'/examples/webpack-options',
'/examples/rollup',
'/examples/sass-and-ts',
]
const runTests = async (dir) => {
try {
chdir(dir)
console.log(`Running yarn install in project ${dir}`)
await execa('yarn', ['install', '--frozen-lockfile'], { stdout: 'inherit' })
console.log(`Running yarn test in project ${dir}`)
await execa('yarn', [
'test',
'--reporter',
'cypress-circleci-reporter',
'--reporter-options',
`resultsDir=${testResultsDestination}`,
], { stdout: 'inherit' })
} catch (e) {
if (!e.stdout) {
// for unexpected errors, just log the entire thing.
console.error(e)
} else {
console.error(e.stdout)
console.error(`Exiting with exit code ${e.exitCode}`)
process.exit(e.exitCode)
}
}
}
const main = async () => {
const NODE_INDEX = process.env.CIRCLE_NODE_INDEX
// initial working directory is npm/react
const projectDir = `${__dirname}${REACT_PROJECTS_FOR_CI[NODE_INDEX]}`
console.log(`Running tests in ${projectDir}`)
await runTests(projectDir)
}
// execute main function if called from command line
if (require.main === module) {
main()
}

View File

@@ -1,6 +1,4 @@
import unfetch from 'unfetch'
export function setupHooks () {
export function setupHooks (rootId: string) {
// @ts-ignore
const isComponentSpec = () => true
@@ -10,8 +8,7 @@ export function setupHooks () {
Cypress.Commands.overwrite('visit', (visit, ...args: any[]) => {
if (isComponentSpec()) {
throw new Error(
'cy.visit from a component spec is not allowed\n' +
'see https://github.com/bahmutov/@cypress/react/issues/286',
'cy.visit from a component spec is not allowed',
)
} else {
// allow regular visit to proceed
@@ -19,11 +16,8 @@ export function setupHooks () {
}
})
/** Initialize an empty document with root element */
/** This function stays here only for old experimental component-testing */
function renderTestingPlatform () {
// Let's mount components under a new div with this id
const rootId = 'cypress-root'
if (document.getElementById(rootId)) {
return
}
@@ -38,35 +32,6 @@ export function setupHooks () {
return cy.get(selector, { log: false })
}
/**
* Replaces window.fetch with a polyfill based on XMLHttpRequest
* that Cypress can spy on and stub
* @see https://www.cypress.io/blog/2020/06/29/experimental-fetch-polyfill/
*/
function polyfillFetchIfNeeded () {
// @ts-ignore
if (Cypress.config('experimentalFetchPolyfill')) {
// @ts-ignore
if (!cy.state('fetchPolyfilled')) {
// TypeScript v4 checks if the property to be deleted is optional
// @ts-ignore
delete window.fetch
window.fetch = unfetch
// @ts-ignore
cy.state('fetchPolyfilled', true)
}
}
}
before(() => {
if (!isComponentSpec()) {
return
}
polyfillFetchIfNeeded()
renderTestingPlatform()
})
/**
* Remove any style or extra link elements from the iframe placeholder
* left from any previous test
@@ -94,5 +59,12 @@ export function setupHooks () {
})
}
beforeEach(cleanupStyles)
beforeEach(() => {
if (!isComponentSpec()) {
return
}
renderTestingPlatform()
cleanupStyles()
})
}

View File

@@ -4,19 +4,16 @@ import getDisplayName from './getDisplayName'
import { injectStylesBeforeElement } from './utils'
import { setupHooks } from './hooks'
// @ts-ignore
export * from 'cypress-react-selector'
const ROOT_ID = '__cy_root'
const rootId = 'cypress-root'
setupHooks()
setupHooks(ROOT_ID)
/**
* Inject custom style text or CSS file or 3rd party style resources
*/
const injectStyles = (options: MountOptions) => {
return () => {
const el = document.getElementById(rootId)
const el = document.getElementById(ROOT_ID)
return injectStylesBeforeElement(options, document, el)
}
@@ -66,14 +63,12 @@ export const mount = (jsx: React.ReactNode, options: MountOptions = {}) => {
.then(() => {
const reactDomToUse = options.ReactDom || ReactDOM
const el = document.getElementById(rootId)
const el = document.getElementById(ROOT_ID)
if (!el) {
throw new Error(
[
'[@cypress/react] 🔥 Hmm, cannot find root element to mount the component.',
'Did you forget to include the support file?',
'Check https://github.com/bahmutov/cypress-react-unit-test#install please',
].join(' '),
)
}
@@ -125,9 +120,10 @@ export const mount = (jsx: React.ReactNode, options: MountOptions = {}) => {
cy
.wrap(userComponent, { log: false })
.as(displayName)
// by waiting, we give the component's hook a chance to run
// by waiting, we delaying test execution for the next tick of event loop
// and letting hooks and component lifecycle methods to execute mount
// https://github.com/bahmutov/cypress-react-unit-test/issues/200
.wait(1, { log: false })
.wait(0, { log: false })
.then(() => {
if (logInstance) {
logInstance.snapshot('mounted')
@@ -161,7 +157,7 @@ export const mount = (jsx: React.ReactNode, options: MountOptions = {}) => {
export const unmount = () => {
return cy.then(() => {
cy.log('unmounting...')
const selector = `#${rootId}`
const selector = `#${ROOT_ID}`
return cy.get(selector, { log: false }).then(($el) => {
unmountComponentAtNode($el[0])

View File

View File

@@ -1,6 +0,0 @@
// should be loaded from cypress.json as a support file
// "supportFile": "node_modules/@cypress/react/support"
// adds commands from @cypress/react
require('cypress-react-selector')
require('@cypress/code-coverage/support')

View File

@@ -1,9 +0,0 @@
{
"extends": "./tsconfig.bin.json",
"compilerOptions": {
"types": [
"mocha",
"node"
]
}
}

View File

@@ -1,32 +0,0 @@
const path = require('path')
const babelConfig = require('./babel.config')
const BUILD_DIR = path.resolve(__dirname, 'public')
const APP_DIR = path.resolve(__dirname, 'src')
/** @type import("webpack").Configuration */
const config = {
entry: `${APP_DIR}/index.jsx`,
output: {
path: BUILD_DIR,
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.(js|jsx|mjs|ts|tsx)$/,
loader: 'babel-loader',
include: APP_DIR,
options: babelConfig,
},
{
test: /\.css$/,
exclude: [/node_modules/],
include: APP_DIR,
use: ['style-loader', 'css-loader'],
},
],
},
}
module.exports = config

View File

@@ -4,8 +4,8 @@
"private": true,
"scripts": {
"build": "vue-cli-service build",
"cy:open": "../../node_modules/.bin/cypress open",
"cy:run": "../../node_modules/.bin/cypress run",
"cy:open": "node ../../../../scripts/cypress open",
"cy:run": "node ../../../../scripts/cypress run",
"serve": "vue-cli-service serve"
},
"dependencies": {

View File

@@ -12,8 +12,6 @@
"watch": "tsc -w"
},
"dependencies": {
"@cypress/code-coverage": "3.8.1",
"@cypress/webpack-dev-server": "0.0.0-development",
"@vue/test-utils": "1.0.3",
"unfetch": "4.1.0"
},
@@ -21,6 +19,8 @@
"@babel/core": "7.9.0",
"@babel/plugin-transform-modules-commonjs": "7.10.4",
"@babel/preset-env": "7.9.5",
"@cypress/code-coverage": "3.8.1",
"@cypress/webpack-dev-server": "0.0.0-development",
"@intlify/vue-i18n-loader": "1.0.0",
"@vue/cli-plugin-babel": "~4.4.0",
"@vue/cli-service": "~4.4.0",
@@ -45,6 +45,7 @@
"webpack": "4.42.0"
},
"peerDependencies": {
"@cypress/webpack-dev-server": "*",
"babel-loader": "8",
"cypress": ">=4.5.0",
"vue": "2.x"
@@ -68,6 +69,11 @@
"cypress",
"vue"
],
"peerDependenciesMeta": {
"@cypress/webpack-dev-server": {
"optional": true
}
},
"publishConfig": {
"access": "public",
"registry": "http://registry.npmjs.org/"

View File

@@ -6,6 +6,7 @@ import {
VueTestUtilsConfigOptions,
Wrapper,
} from '@vue/test-utils'
import { renderTestingPlatform, ROOT_ID } from './renderTestingPlatform'
const defaultOptions: (keyof MountOptions)[] = [
'vue',
@@ -357,15 +358,11 @@ export const mount = (
const document: Document = cy.state('document')
document.body.innerHTML = ''
let el = document.getElementById('cypress-jsdom')
let el = document.getElementById(ROOT_ID)
// If the target div doesn't exist, create it
if (!el) {
const div = document.createElement('div')
div.id = 'cypress-jsdom'
document.body.appendChild(div)
el = div
el = renderTestingPlatform(document.head.innerHTML)
}
if (typeof options.stylesheets === 'string') {

View File

@@ -17,7 +17,6 @@ const { startDevServer } = require('@cypress/webpack-dev-server')
* }
*/
const cypressPluginsFn = (on, config, webpackConfig) => {
require('@cypress/code-coverage/task')(on, config)
on('dev-server:start', (options) => startDevServer({ options, webpackConfig }))
return config

View File

@@ -0,0 +1,20 @@
export const ROOT_ID = '__cy_root'
/** Initialize an empty document with root element
* This only needs for experimentalComponentTesting
*/
export function renderTestingPlatform (headInnerHTML: string) {
// @ts-expect-error no idea
const document = cy.state('document')
if (document.body) document.body.innerHTML = ''
if (document.head) document.head.innerHTML = headInnerHTML
const rootNode = document.createElement('div')
rootNode.setAttribute('id', ROOT_ID)
document.getElementsByTagName('body')[0].prepend(rootNode)
return rootNode
}

View File

@@ -1,47 +1,11 @@
/* eslint-env mocha */
import unfetch from 'unfetch'
require('@cypress/code-coverage/support')
const { renderTestingPlatform } = require('./renderTestingPlatform')
let headInnerHTML = document.head.innerHTML
/** Initialize an empty document with root element */
function renderTestingPlatform () {
const document = cy.state('document')
if (document.body) document.body.innerHTML = ''
if (document.head) document.head.innerHTML = headInnerHTML
const rootNode = document.createElement('div')
rootNode.setAttribute('id', 'cypress-jsdom')
document.getElementsByTagName('body')[0].prepend(rootNode)
return cy.get('#cypress-jsdom', { log: false })
}
/**
* Replaces window.fetch with a polyfill based on XMLHttpRequest
* that Cypress can spy on and stub
* @see https://www.cypress.io/blog/2020/06/29/experimental-fetch-polyfill/
*/
function polyfillFetchIfNeeded () {
// @ts-ignore
if (Cypress.config('experimentalFetchPolyfill')) {
// @ts-ignore
if (!cy.state('fetchPolyfilled')) {
delete window.fetch
window.fetch = unfetch
// @ts-ignore
cy.state('fetchPolyfilled', true)
}
}
}
beforeEach(() => {
renderTestingPlatform()
polyfillFetchIfNeeded()
renderTestingPlatform(headInnerHTML)
})
before(() => {

View File

@@ -1,16 +0,0 @@
version: 2.1
orbs:
node: circleci/node@1.1.6
jobs:
build:
executor:
name: node/default
tag: '12'
steps:
- checkout
- node/with-cache:
steps:
- run: yarn
- run: yarn lint
- run: yarn test
- run: yarn semantic-release || true

View File

@@ -1,14 +0,0 @@
version: 2.1
orbs:
node: circleci/node@1.1.6
jobs:
build:
executor:
name: node/default
tag: '12'
steps:
- checkout
- node/with-cache:
steps:
- run: yarn
- run: yarn test

View File

@@ -7,6 +7,5 @@
<title>Components App</title>
</head>
<body>
<div id="app"></div>
</body>
</html>

View File

@@ -11,6 +11,7 @@
},
"dependencies": {
"debug": "4.3.2",
"lazy-compile-webpack-plugin": "0.1.11",
"semver": "^7.3.4",
"webpack-merge": "^5.4.0"
},

Some files were not shown because too many files have changed in this diff Show More