Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit 382124d

Browse files
authored
add a folder with react-scripts example (#183)
This is a start, need to add another example where component spec is outside the `src` folder for #178
1 parent 083ab73 commit 382124d

27 files changed

+21828
-11013
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
public/
22
node_modules/
33
dist
4-
cypress/videos
5-
cypress/screenshots
4+
**/cypress/videos
5+
**/cypress/screenshots
6+
package-lock.json
7+
.nyc_output
8+
coverage

circle.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2.1
22
orbs:
3-
cypress: cypress-io/cypress@1
3+
cypress: cypress-io/cypress@1.21.0
44
workflows:
55
build:
66
jobs:
@@ -21,6 +21,18 @@ workflows:
2121
name: Build folder 🏗
2222
command: npm run build
2323

24+
- cypress/run:
25+
name: Example React Scripts
26+
requires:
27+
- Install
28+
# each example installs "cypress-react-unit-test" as a local dependency (symlink)
29+
install-command: npm install
30+
verify-command: echo 'Already verified'
31+
no-workspace: true
32+
working_directory: examples/react-scripts
33+
command: npm test
34+
store_artifacts: true
35+
2436
- cypress/run:
2537
name: Test
2638
parallelism: 4
@@ -32,6 +44,7 @@ workflows:
3244
# we are not going to use results from this job anywhere else
3345
no-workspace: true
3446
record: false
47+
store_artifacts: true
3548
# following examples from
3649
# https://circleci.com/docs/2.0/parallelism-faster-jobs/
3750
command: |
@@ -49,7 +62,9 @@ workflows:
4962
requires:
5063
- Install
5164
- Test
52-
install-command: echo 'Nothing to install in this job'
65+
- Example React Scripts
66+
install-command: echo 'Already installed'
67+
verify-command: echo 'Already verified'
5368
no-workspace: true
5469
# instead of "cypress run" do NPM release 😁
5570
# clear environment variables to trick semantic-release

examples/react-scripts/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"fixturesFolder": false,
3+
"testFiles": "**/*.cy-spec.js",
4+
"viewportWidth": 500,
5+
"viewportHeight": 500,
6+
"experimentalComponentTesting": true,
7+
"componentFolder": "src"
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference types="cypress" />
2+
describe('integration spec', () => {
3+
it('works', () => {
4+
expect(1).to.equal(1)
5+
})
6+
})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const preprocessor = require('../../../../plugins/react-scripts')
2+
module.exports = (on, config) => {
3+
preprocessor(on, config)
4+
// IMPORTANT to return the config object
5+
// with the any changed environment variables
6+
return config
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('cypress-react-unit-test/support')
2+
require('@cypress/code-coverage/support')
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "example-react-scripts",
3+
"description": "Component testing with specs inside the src folder",
4+
"private": true,
5+
"scripts": {
6+
"test": "../../node_modules/.bin/cypress run",
7+
"cy:open": "../../node_modules/.bin/cypress open"
8+
},
9+
"devDependencies": {
10+
"cypress-react-unit-test": "file:../.."
11+
}
12+
}
3.08 KB
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
14+
manifest.json provides metadata used when your web app is installed on a
15+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16+
-->
17+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tags above.
20+
It will be replaced with the URL of the `public` folder during the build.
21+
Only files inside the `public` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running `npm run build`.
26+
-->
27+
<title>React App</title>
28+
</head>
29+
<body>
30+
<noscript>You need to enable JavaScript to run this app.</noscript>
31+
<div id="root"></div>
32+
<!--
33+
This HTML file is a template.
34+
If you open it directly in the browser, you will see an empty page.
35+
36+
You can add webfonts, meta tags, or analytics to this file.
37+
The build step will place the bundled scripts into the <body> tag.
38+
39+
To begin the development, run `npm start` or `yarn start`.
40+
To create a production bundle, use `npm run build` or `yarn build`.
41+
-->
42+
</body>
43+
</html>

0 commit comments

Comments
 (0)