-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experiment/add cypress for e2e tests (#8282)
* chore(react): add cypress and initial accordion test * wip: check in work * wip: check in work * chore: check in work * chore(project): run cypress in ci * testing(accordion): enable percy snapshots, configure cypress eslint plugin * chore(eslint): revert readme changes * chore(cli): move '@percy/cli' dep from react to cli package * chore(yarn): include cache from '@percy/cli' install * chore(project): update yarn cache checksums * chore: clear cache * chore: add cache * chore: fix yarn cache * chore: i think i finally fixed the cache * fix(cli): modify command for percy e2e * fix(project): update to cypress v7, retool configuration * chore(project): move percy cli dep to root * chore(project): turn off cypress videos and snapshots in CI * chore(cypress): update command syntax * chore(cypress): update command syntax * fix(ci): correct command for jest e2e tests * chore: run yarn dedupe Co-authored-by: Josh Black <[email protected]>
- Loading branch information
1 parent
ce06628
commit 428d3d5
Showing
159 changed files
with
1,600 additions
and
131 deletions.
There are no files selected for viewing
Binary file added
BIN
+3.84 KB
.yarn/cache/@cypress-listr-verbose-renderer-npm-0.4.1-87829e7b0f-0169c2b30f.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+17.7 KB
.yarn/cache/@cypress-webpack-dev-server-npm-1.1.5-4464468c5b-27844415fe.zip
Binary file not shown.
Binary file added
BIN
+12.5 KB
.yarn/cache/@cypress-webpack-preprocessor-npm-5.7.0-f8ca8f5ece-d5be64f028.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+7.27 KB
.yarn/cache/@percy-cli-build-npm-1.0.0-beta.48-5cfe5c33e8-25172333e2.zip
Binary file not shown.
Binary file added
BIN
+5.94 KB
.yarn/cache/@percy-cli-command-npm-1.0.0-beta.48-c575a2bdcd-823a2dadf4.zip
Binary file not shown.
Binary file added
BIN
+7.83 KB
.yarn/cache/@percy-cli-config-npm-1.0.0-beta.48-1ea3369158-b710f2edd6.zip
Binary file not shown.
Binary file added
BIN
+10.1 KB
.yarn/cache/@percy-cli-exec-npm-1.0.0-beta.48-60b5deb25d-f3f45c83b9.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+8.04 KB
.yarn/cache/@percy-cli-snapshot-npm-1.0.0-beta.48-1fc7cb266c-b8667f5a50.zip
Binary file not shown.
Binary file added
BIN
+7.55 KB
.yarn/cache/@percy-cli-upload-npm-1.0.0-beta.48-a08fce8173-b6fa846193.zip
Binary file not shown.
Binary file added
BIN
+10.3 KB
.yarn/cache/@percy-client-npm-1.0.0-beta.48-1c1e954db2-992e39ff3c.zip
Binary file not shown.
Binary file added
BIN
+10.6 KB
.yarn/cache/@percy-config-npm-1.0.0-beta.48-ac577fcf86-1a3af67d02.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+15.3 KB
.yarn/cache/@percy-logger-npm-1.0.0-beta.48-293f476887-133a99ad4d.zip
Binary file not shown.
Binary file added
BIN
+19.8 KB
.yarn/cache/@percy-sdk-utils-npm-1.0.0-beta.48-d9e648a024-c09516e618.zip
Binary file not shown.
Binary file added
BIN
+12.2 KB
.yarn/cache/@testing-library-cypress-npm-7.0.6-ea01546236-d7a2d3f185.zip
Binary file not shown.
Binary file removed
BIN
-599 KB
.yarn/cache/@testing-library-dom-npm-7.26.6-161cd7b2eb-d4b3fa5e89.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+5.44 KB
.yarn/cache/@types-sinonjs__fake-timers-npm-6.0.2-aa66b2ff89-fe62eec9cf.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+26.4 KB
...debug-npm-3.2.6-6214e40f12-07bc8b3a13.zip → ...debug-npm-3.2.7-754e818c7a-b3d8c59407.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+19.2 KB
.yarn/cache/eslint-plugin-cypress-npm-2.11.2-d1caa76747-b1e68f13d7.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+7.36 KB
.yarn/cache/find-yarn-workspace-root-npm-1.2.1-91f28f6b79-a8f4565fb1.zip
Binary file not shown.
Binary file added
BIN
+7.43 KB
.yarn/cache/find-yarn-workspace-root-npm-2.0.0-e58a501607-fa5ca8f9d0.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+17.9 KB
.yarn/cache/http-proxy-middleware-npm-0.19.1-ba4e5c6109-64df043841.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.82 KB
.yarn/cache/is-installed-globally-npm-0.4.0-a30dd056c7-3359840d59.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+3.4 KB
.yarn/cache/multicast-dns-service-types-npm-1.1.0-d019ff060c-0979fca1cc.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+26.8 KB
...river-npm-0.7.3-61bc863185-22e14295f4.zip → ...river-npm-0.7.4-a72739da70-fffe5a33fe.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+77.3 KB
...args-npm-13.3.0-3e763c27c3-50aac9a724.zip → ...args-npm-13.3.2-1588f5dd4c-75c13e837e.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright IBM Corp. 2018, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
plugins: ['eslint-plugin-cypress'], | ||
overrides: [ | ||
{ | ||
files: ['*-test.e2e.js'], | ||
extends: ['plugin:cypress/recommended'], | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"componentFolder": "src", | ||
"env": { | ||
"coverage": false | ||
}, | ||
"fixturesFolder": false, | ||
"nodeVersion": "system", | ||
"testFiles": "**/*-test.e2e.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
module.exports = (on, config) => { | ||
if (config.testingType === 'component') { | ||
const { startDevServer } = require('@cypress/webpack-dev-server'); | ||
const webpackConfig = require('../../webpack.config.js'); | ||
|
||
on('dev-server:start', (options) => | ||
startDevServer({ options, webpackConfig }) | ||
); | ||
} | ||
|
||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// https://github.com/dmtrKovalenko/cypress-real-events | ||
import 'cypress-real-events/support'; | ||
|
||
// https://github.com/testing-library/cypress-testing-library | ||
import '@testing-library/cypress/add-commands'; | ||
|
||
// https://github.com/percy/percy-cypress | ||
import '@percy/cypress'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/react/src/components/Accordion/__tests__/Accordion-test.e2e.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import 'carbon-components/scss/components/accordion/_accordion.scss'; | ||
|
||
import React from 'react'; | ||
import { mount } from '@cypress/react'; | ||
import { default as Accordion, AccordionItem } from '..'; | ||
|
||
describe('Accordion', () => { | ||
beforeEach(() => { | ||
mount( | ||
<Accordion> | ||
<AccordionItem title="Section 1">Panel 1</AccordionItem> | ||
<AccordionItem title="Section 2">Panel 2</AccordionItem> | ||
<AccordionItem title="Section 3">Panel 3</AccordionItem> | ||
</Accordion> | ||
); | ||
}); | ||
|
||
it('should render', () => { | ||
cy.findByText(/Section 1/).should('be.visible'); | ||
cy.findByText(/Section 2/).should('be.visible'); | ||
cy.findByText(/Section 3/).should('be.visible'); | ||
|
||
cy.findByText(/Panel 1/).should('not.be.visible'); | ||
cy.findByText(/Panel 2/).should('not.be.visible'); | ||
cy.findByText(/Panel 3/).should('not.be.visible'); | ||
|
||
// snapshots should always be taken _after_ an assertion that | ||
// a element/component should be visible. This is to ensure | ||
// the DOM has settled and the element has fully loaded. | ||
cy.percySnapshot(); | ||
}); | ||
|
||
it('should tab between items and open on space', () => { | ||
// in order for realPress('Tab') to work, something must be focused first. | ||
// cy.get('body').focus() does not work | ||
// cy.get('body').realClick() does not work because the click seems to be happen at the center of the element, which opens an accordion item | ||
cy.findByRole('button', { name: /Section 1/i }).focus(); | ||
|
||
cy.realPress('Tab'); | ||
cy.findByRole('button', { name: /Section 2/i }).should('be.focused'); | ||
|
||
cy.realPress('Tab'); | ||
cy.findByRole('button', { name: /Section 3/i }) | ||
.should('be.focused') | ||
.realPress('Space'); | ||
cy.findByText(/Panel 1/).should('not.be.visible'); | ||
cy.findByText(/Panel 2/).should('not.be.visible'); | ||
cy.findByText(/Panel 3/).should('be.visible'); | ||
// snapshots should always be taken _after_ an assertion that | ||
// a element/component should be visible. This is to ensure | ||
// the DOM has settled and the element has fully loaded. | ||
cy.percySnapshot(); | ||
|
||
cy.realPress(['Shift', 'Tab']); | ||
cy.realPress('Space'); | ||
cy.realPress(['Shift', 'Tab']); | ||
cy.realPress('Space'); | ||
|
||
cy.findByText(/Panel 1/).should('be.visible'); | ||
cy.findByText(/Panel 2/).should('be.visible'); | ||
cy.findByText(/Panel 3/).should('be.visible'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [require.resolve('./scripts/env.js')], | ||
}, | ||
}, | ||
{ | ||
test: /\.s?css$/i, | ||
use: [ | ||
'style-loader', | ||
'css-loader', | ||
{ | ||
loader: 'sass-loader', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; |
Oops, something went wrong.