Skip to content
This repository was archived by the owner on Jun 16, 2024. It is now read-only.

Commit 545d178

Browse files
committed
test: add cypress tests
1 parent 7c78794 commit 545d178

File tree

14 files changed

+1484
-77
lines changed

14 files changed

+1484
-77
lines changed

__snapshots__/compilation.spec.ts.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
exports['rollup createPreprocessor - e2e correctly preprocesses the file 1'] = `
1+
exports['compilation - e2e correctly preprocesses the file 1'] = `
22
(function (factory) {
33
typeof define === 'function' && define.amd ? define(factory) :
44
factory();
@@ -16,7 +16,7 @@ exports['rollup createPreprocessor - e2e correctly preprocesses the file 1'] = `
1616
1717
`
1818

19-
exports['rollup createPreprocessor - e2e correctly preprocesses the file using plugins 1'] = `
19+
exports['compilation - e2e correctly preprocesses the file using plugins 1'] = `
2020
(function (factory) {
2121
typeof define === 'function' && define.amd ? define(factory) :
2222
factory();
@@ -31,7 +31,7 @@ exports['rollup createPreprocessor - e2e correctly preprocesses the file using p
3131
3232
`
3333

34-
exports['rollup createPreprocessor - e2e correctly reprocesses the file after a modification 1'] = `
34+
exports['compilation - e2e correctly reprocesses the file after a modification 1'] = `
3535
(function (factory) {
3636
\ttypeof define === 'function' && define.amd ? define(factory) :
3737
\tfactory();
@@ -43,10 +43,10 @@ exports['rollup createPreprocessor - e2e correctly reprocesses the file after a
4343
4444
`
4545

46-
exports['rollup createPreprocessor - e2e has less verbose "Module not found" error 1'] = `
46+
exports['compilation - e2e has less verbose "Module not found" error 1'] = `
4747
Could not resolve './does/not-exist' from test/_test-output/imports_nonexistent_file_spec.js
4848
`
4949

50-
exports['rollup createPreprocessor - e2e has less verbose syntax error 1'] = `
50+
exports['compilation - e2e has less verbose syntax error 1'] = `
5151
Unexpected token
5252
`

__snapshots__/cypress.spec.ts.js

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
exports['cypress - e2e test: cypress integration 1'] = `
2+
3+
====================================================================================================
4+
5+
(Run Starting)
6+
7+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
8+
│ Cypress: *.*.* │
9+
│ Browser: Electron ** (headless) │
10+
│ Specs: 3 found (compile-error.spec.js, fail.spec.js, success.spec..js) │
11+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
12+
13+
14+
────────────────────────────────────────────────────────────────────────────────────────────────────
15+
16+
Running: compile-error.spec.js (1 of 3)
17+
18+
Oops...we found an error preparing this test file:
19+
20+
cypress/integration/compile-error.spec.js
21+
22+
The error was:
23+
24+
Error: Unexpected token
25+
26+
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
27+
28+
- A missing file or dependency
29+
- A syntax error in the file or one of its dependencies
30+
31+
Fix the error in your code and re-run your tests.
32+
33+
(Results)
34+
35+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
36+
│ Tests: 0 │
37+
│ Passing: 0 │
38+
│ Failing: 1 │
39+
│ Pending: 0 │
40+
│ Skipped: 0 │
41+
│ Screenshots: 0 │
42+
│ Video: false │
43+
│ Duration: 0 seconds │
44+
│ Spec Ran: compile-error.spec.js │
45+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
46+
47+
48+
────────────────────────────────────────────────────────────────────────────────────────────────────
49+
50+
Running: fail.spec.js (2 of 3)
51+
52+
53+
foo
54+
1) fails
55+
56+
57+
0 passing (***ms)
58+
1 failing
59+
60+
1) foo
61+
fails:
62+
63+
AssertionError: expected 1 to be above 1
64+
+ expected - actual
65+
66+
67+
at Context.eval (http://localhost:****/__cypress/tests?p=cypress/integration/fail.spec.js:8:23)
68+
69+
70+
71+
72+
(Results)
73+
74+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
75+
│ Tests: 1 │
76+
│ Passing: 0 │
77+
│ Failing: 1 │
78+
│ Pending: 0 │
79+
│ Skipped: 0 │
80+
│ Screenshots: 0 │
81+
│ Video: false │
82+
│ Duration: 0 seconds │
83+
│ Spec Ran: fail.spec.js │
84+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
85+
86+
87+
────────────────────────────────────────────────────────────────────────────────────────────────────
88+
89+
Running: success.spec..js (3 of 3)
90+
91+
92+
foo
93+
✓ runs (***ms)
94+
95+
96+
1 passing (***ms)
97+
98+
99+
(Results)
100+
101+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
102+
│ Tests: 1 │
103+
│ Passing: 1 │
104+
│ Failing: 0 │
105+
│ Pending: 0 │
106+
│ Skipped: 0 │
107+
│ Screenshots: 0 │
108+
│ Video: false │
109+
│ Duration: 0 seconds │
110+
│ Spec Ran: success.spec..js │
111+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
112+
113+
114+
====================================================================================================
115+
116+
(Run Finished)
117+
118+
119+
Spec Tests Passing Failing Pending Skipped
120+
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
121+
│ ✖ compile-error.spec.js ***ms - - 1 - - │
122+
├────────────────────────────────────────────────────────────────────────────────────────────────┤
123+
│ ✖ fail.spec.js ***ms 1 - 1 - - │
124+
├────────────────────────────────────────────────────────────────────────────────────────────────┤
125+
│ ✔ success.spec..js ***ms 1 1 - - - │
126+
└────────────────────────────────────────────────────────────────────────────────────────────────┘
127+
✖ 2 of 3 failed (67%) ***ms 2 1 2 - -
128+
129+
130+
`

cypress.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"fixturesFolder": false,
3+
"supportFile": false,
4+
"video": false,
5+
"screenshotOnRunFailure": false
6+
}

cypress/.eslintrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": [
3+
"plugin:cypress/recommended"
4+
],
5+
"plugins": [
6+
"cypress"
7+
]
8+
}

cypress/integration/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./compile-error.js
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
describe('foo', () => {
2+
it('has syntax error'() => {}})
3+
})

cypress/integration/fail.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('foo', () => {
2+
it('fails', () => {
3+
expect(1).to.be.greaterThan(1)
4+
})
5+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('foo', () => {
2+
it('runs', () => {
3+
expect(1).to.be.greaterThan(0)
4+
})
5+
})

cypress/plugins/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference types="cypress" />
2+
3+
const rollupPreprocessor = require('../../dist')
4+
5+
/**
6+
* @type {Cypress.PluginConfig}
7+
*/
8+
module.exports = (on) => {
9+
on('file:preprocessor', rollupPreprocessor())
10+
}

cypress/tsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"types": ["cypress"]
5+
}
6+
}

0 commit comments

Comments
 (0)