Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 1fecb5b

Browse files
authored
chore: add e2e test, refactor/lint, upgrade deps (#62)
add e2e test adds e2e test that snapshots cypress stdout refactor/ lint rename tests/snapshots lint files add yarn.lock upgrade deps upgrade eslint and use new eslint deps
1 parent 175abcf commit 1fecb5b

23 files changed

+10379
-55
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test/_test-output
2+
cypress/tests/e2e/compile-error.js
3+
test/fixtures

.eslintrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.eslintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": [
3+
"@cypress/dev"
4+
],
5+
"extends": [
6+
"plugin:@cypress/dev/general"
7+
],
8+
"env": {
9+
"node": true
10+
}
11+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ node_modules/
22
.DS_Store
33
*.log*
44
_test-output
5+
cypress/videos
6+
cypress/screenshots

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.9.3
1+
8.12.0
File renamed without changes.

__snapshots__/e2e.spec.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
exports['can test test: cypress/tests/e2e/compile-error.js 1'] = `
2+
3+
====================================================================================================
4+
5+
(Run Starting)
6+
7+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
8+
│ Cypress: 1.2.3 │
9+
│ Browser: FooBrowser 88 │
10+
│ Specs: 1 found (e2e/compile-error.js) │
11+
│ Searched: cypress/tests/e2e/compile-error.js │
12+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
13+
14+
15+
────────────────────────────────────────────────────────────────────────────────────────────────────
16+
17+
Running: e2e/compile-error.js (1 of 1)
18+
19+
Oops...we found an error preparing this test file:
20+
21+
cypress/tests/e2e/compile-error.js
22+
23+
The error was:
24+
25+
./cypress/tests/e2e/compile-error.js
26+
Module build failed (from ./node_modules/babel-loader/lib/index.js):
27+
SyntaxError: /[cwd]/cypress/tests/e2e/compile-error.js: Unexpected token, expected "," (12:27)
28+
29+
10 |
30+
11 | describe('foo', ()=>{
31+
> 12 | it('has syntax error' () => {}})
32+
| ^
33+
13 | })
34+
14 |
35+
36+
@ multi ./cypress/tests/e2e/compile-error.js main[0]
37+
38+
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
39+
40+
- A missing file or dependency
41+
- A syntax error in the file or one of its dependencies
42+
43+
Fix the error in your code and re-run your tests.
44+
45+
(Results)
46+
47+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
48+
│ Tests: 0 │
49+
│ Passing: 0 │
50+
│ Failing: 1 │
51+
│ Pending: 0 │
52+
│ Skipped: 0 │
53+
│ Screenshots: 0 │
54+
│ Video: true │
55+
│ Duration: X seconds │
56+
│ Spec Ran: e2e/compile-error.js │
57+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
58+
59+
60+
(Video)
61+
62+
- Started processing: Compressing to 32 CRF
63+
- Finished processing: /[cwd]/cypress/videos/e2e/compile-error.js.mp4 (X second)
64+
65+
66+
====================================================================================================
67+
68+
(Run Finished)
69+
70+
71+
Spec Tests Passing Failing Pending Skipped
72+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
73+
│ ✖ e2e/compile-error.js XX:XX - - 1 - - │
74+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
75+
✖ 1 of 1 failed (100%) XX:XX - - 1 - -
76+
77+
78+
`

circle.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,27 @@ workflows:
99
jobs:
1010
test:
1111
docker:
12-
- image: circleci/node:8
12+
- image: cypress/base:8
1313

1414
steps:
1515
- checkout
16-
16+
17+
- restore_cache:
18+
keys:
19+
- cache-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
1720
- run:
18-
name: Install dependencies
19-
command: npm install
20-
21+
name: Yarn install
22+
command: yarn install --frozen-lockfile
23+
- save_cache:
24+
key: cache-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
25+
paths:
26+
- ~/.cache
2127
- run:
2228
name: Lint code
2329
command: npm run lint
24-
30+
- run:
31+
name: Cypress Verfiy
32+
command: $(npm bin)/cypress verify
2533
- run:
2634
name: Run tests
2735
command: npm test

cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"integrationFolder": "cypress/tests"
3+
}

cypress/plugins/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************************
3+
// This example plugins/index.js can be used to load plugins
4+
//
5+
// You can change the location of this file or turn off loading
6+
// the plugins file with the 'pluginsFile' configuration option.
7+
//
8+
// You can read more here:
9+
// https://on.cypress.io/plugins-guide
10+
// ***********************************************************
11+
12+
// This function is called when a project is opened or re-opened (e.g. due to
13+
// the project's config changing)
14+
15+
const webpack = require('../../')
16+
17+
// const webpackOptions = require('@packages/runner/webpack.config.ts').default
18+
19+
/**
20+
* @type {Cypress.PluginConfig}
21+
*/
22+
module.exports = (on) => {
23+
// on('file:preprocessor', webpack({ webpackOptions }))
24+
on('file:preprocessor', webpack({ }))
25+
}

cypress/support/commands.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

cypress/support/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js 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+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

cypress/tests/e2e/compile-error.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference types="cypress"/>
2+
/* eslint-disable */
3+
4+
5+
/* EXPECT: {
6+
expectedResults: {
7+
totalFailed: 1
8+
}
9+
} */
10+
11+
describe('foo', ()=>{
12+
it('has syntax error' () => {}})
13+
})

deferred.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const createDeferred = () => {
77
deferred.resolve = resolve
88
deferred.reject = reject
99
})
10+
1011
return deferred
1112
}
1213

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const preprocessor = (options = {}) => {
101101
// the `handle` function below and its promise is what is ultimately
102102
// returned from this function
103103
let latestBundle = createDeferred()
104+
104105
// cache the bundle promise, so it can be returned if this function
105106
// is invoked again with the same filePath
106107
bundles[filePath] = latestBundle.promise
@@ -125,6 +126,7 @@ const preprocessor = (options = {}) => {
125126
if (stats.hasErrors()) {
126127
err = new Error('Webpack Compilation Error')
127128
err.stack = jsonStats.errors.join('\n\n')
129+
128130
return rejectWithErr(err)
129131
}
130132

package.json

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,46 @@
11
{
22
"name": "@cypress/webpack-preprocessor",
3-
"description": "Cypress preprocessor for bundling JavaScript via webpack",
43
"version": "0.0.0-development",
5-
"author": "Chris Breiding <[email protected]>",
6-
"bugs": "https://github.com/cypress-io/cypress-webpack-preprocessor/issues",
7-
"files": [
8-
"*.js"
9-
],
4+
"description": "Cypress preprocessor for bundling JavaScript via webpack",
105
"private": false,
11-
"homepage": "https://github.com/cypress-io/cypress-webpack-preprocessor#readme",
12-
"keywords": [
13-
"cypress",
14-
"cypress-plugin",
15-
"cypress-preprocessor",
16-
"webpack"
17-
],
18-
"license": "MIT",
19-
"repository": {
20-
"type": "git",
21-
"url": "https://github.com/cypress-io/cypress-webpack-preprocessor.git"
22-
},
236
"scripts": {
247
"ban": "ban",
258
"deps": "deps-ok && dependency-check --no-dev .",
269
"license": "license-checker --production --onlyunknown --csv",
27-
"lint": "eslint --fix *.js",
28-
"pretest": "npm run lint",
10+
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json .",
11+
"lint-fix": "yarn lint --fix",
2912
"secure": "nsp check",
13+
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post",
3014
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
15+
"pretest": "npm run lint",
3116
"test": "npm run test-unit && npm run test-e2e",
32-
"test-e2e": "mocha test/e2e/*.js",
33-
"test-unit": "mocha test/unit/*.js",
3417
"test-debug": "node --inspect --debug-brk ./node_modules/.bin/_mocha",
35-
"test-watch": "chokidar '*.js' 'test/unit/*.js' -c 'npm run test-unit'",
36-
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post"
18+
"test-e2e": "mocha test/e2e/*.spec.js",
19+
"test-unit": "mocha test/unit/*.spec.js",
20+
"test-watch": "chokidar '*.js' 'test/unit/*.js' -c 'npm run test-unit'"
21+
},
22+
"dependencies": {
23+
"bluebird": "3.7.1",
24+
"debug": "4.1.1"
3725
},
3826
"devDependencies": {
3927
"@babel/core": "^7.0.1",
4028
"@babel/preset-env": "^7.0.0",
29+
"@cypress/eslint-plugin-dev": "5.0.0",
4130
"babel-loader": "^8.0.2",
4231
"ban-sensitive-files": "1.9.0",
4332
"chai": "4.1.2",
33+
"chalk": "3.0.0",
4434
"chokidar-cli": "1.2.0",
4535
"condition-circle": "1.5.0",
36+
"cypress": "4.0.2",
4637
"dependency-check": "2.9.1",
4738
"deps-ok": "1.2.1",
4839
"dont-crack": "1.2.1",
49-
"eslint": "4.6.1",
50-
"eslint-plugin-cypress-dev": "1.1.1",
40+
"eslint": "6.8.0",
41+
"eslint-plugin-json-format": "2.0.1",
5142
"eslint-plugin-mocha": "4.11.0",
43+
"fast-glob": "3.1.1",
5244
"fs-extra": "8.1.0",
5345
"github-post-release": "1.13.1",
5446
"license-checker": "13.0.3",
@@ -60,21 +52,34 @@
6052
"simple-commit-message": "3.3.1",
6153
"sinon": "3.2.1",
6254
"sinon-chai": "2.13.0",
63-
"snap-shot-it": "7.9.0",
55+
"snap-shot-it": "7.9.2",
6456
"webpack": "^4.18.1"
6557
},
6658
"peerDependencies": {
6759
"webpack": "^4.18.1"
6860
},
61+
"files": [
62+
"*.js"
63+
],
64+
"license": "MIT",
65+
"repository": {
66+
"type": "git",
67+
"url": "https://github.com/cypress-io/cypress-webpack-preprocessor.git"
68+
},
69+
"homepage": "https://github.com/cypress-io/cypress-webpack-preprocessor#readme",
70+
"author": "Chris Breiding <[email protected]>",
71+
"bugs": "https://github.com/cypress-io/cypress-webpack-preprocessor/issues",
72+
"keywords": [
73+
"cypress",
74+
"cypress-plugin",
75+
"cypress-preprocessor",
76+
"webpack"
77+
],
6978
"optionalDependencies": {
7079
"@babel/core": "^7.0.1",
7180
"@babel/preset-env": "^7.0.0",
7281
"babel-loader": "^8.0.2"
7382
},
74-
"dependencies": {
75-
"bluebird": "3.7.1",
76-
"debug": "4.1.1"
77-
},
7883
"release": {
7984
"verifyConditions": "condition-circle",
8085
"analyzeCommits": "simple-commit-message",

test/.eslintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/.eslintrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"plugin:@cypress/dev/tests"
4+
]
5+
}
File renamed without changes.

0 commit comments

Comments
 (0)