Skip to content

Commit db0811c

Browse files
committed
Add examples in cjs
1 parent 1a9d097 commit db0811c

File tree

17 files changed

+269
-0
lines changed

17 files changed

+269
-0
lines changed

.github/workflows/examples.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@ defaults:
1010
shell: bash
1111

1212
jobs:
13+
browserify-cjs:
14+
runs-on: ubuntu-20.04
15+
container:
16+
image: cypress/base:17.3.0
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
- name: Cache NPM modules
21+
uses: actions/cache@v2
22+
with:
23+
path: ~/.npm
24+
key: npm
25+
- name: Cache Cypress binaries
26+
uses: actions/cache@v2
27+
with:
28+
path: ~/.cache/Cypress
29+
key: cypress
30+
# In lack of native support, https://github.com/actions/checkout/issues/172.
31+
- name: Make checkout sparse
32+
run: |
33+
shopt -s extglob
34+
rm -rf examples/!(browserify-cjs)
35+
rm -rf !(examples)
36+
- name: Install NPM modules
37+
working-directory: examples/browserify-cjs
38+
run: npm install
39+
- name: Run Cypress
40+
working-directory: examples/browserify-cjs
41+
run: npx cypress run
42+
1343
browserify-esm:
1444
runs-on: ubuntu-20.04
1545
container:
@@ -70,6 +100,36 @@ jobs:
70100
working-directory: examples/browserify-ts
71101
run: npx cypress run
72102

103+
webpack-cjs:
104+
runs-on: ubuntu-20.04
105+
container:
106+
image: cypress/base:17.3.0
107+
steps:
108+
- name: Checkout
109+
uses: actions/checkout@v2
110+
- name: Cache NPM modules
111+
uses: actions/cache@v2
112+
with:
113+
path: ~/.npm
114+
key: npm
115+
- name: Cache Cypress binaries
116+
uses: actions/cache@v2
117+
with:
118+
path: ~/.cache/Cypress
119+
key: cypress
120+
# In lack of native support, https://github.com/actions/checkout/issues/172.
121+
- name: Make checkout sparse
122+
run: |
123+
shopt -s extglob
124+
rm -rf examples/!(webpack-cjs)
125+
rm -rf !(examples)
126+
- name: Install NPM modules
127+
working-directory: examples/webpack-cjs
128+
run: npm install
129+
- name: Run Cypress
130+
working-directory: examples/webpack-cjs
131+
run: npx cypress run
132+
73133
webpack-esm:
74134
runs-on: ubuntu-20.04
75135
container:
@@ -130,6 +190,36 @@ jobs:
130190
working-directory: examples/webpack-ts
131191
run: npx cypress run
132192

193+
esbuild-cjs:
194+
runs-on: ubuntu-20.04
195+
container:
196+
image: cypress/base:17.3.0
197+
steps:
198+
- name: Checkout
199+
uses: actions/checkout@v2
200+
- name: Cache NPM modules
201+
uses: actions/cache@v2
202+
with:
203+
path: ~/.npm
204+
key: npm
205+
- name: Cache Cypress binaries
206+
uses: actions/cache@v2
207+
with:
208+
path: ~/.cache/Cypress
209+
key: cypress
210+
# In lack of native support, https://github.com/actions/checkout/issues/172.
211+
- name: Make checkout sparse
212+
run: |
213+
shopt -s extglob
214+
rm -rf examples/!(esbuild-cjs)
215+
rm -rf !(examples)
216+
- name: Install NPM modules
217+
working-directory: examples/esbuild-cjs
218+
run: npm install
219+
- name: Run Cypress
220+
working-directory: examples/esbuild-cjs
221+
run: npx cypress run
222+
133223
esbuild-esm:
134224
runs-on: ubuntu-20.04
135225
container:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**/*.js
22
**/*.d.ts
3+
!examples/**/*
34
!features/**/*
45
!cucumber.d.ts
56
!cucumber.js

examples/browserify-cjs/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { defineConfig } = require("cypress");
2+
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
3+
const browserify = require("@badeball/cypress-cucumber-preprocessor/browserify");
4+
5+
async function setupNodeEvents(on, config) {
6+
await preprocessor.addCucumberPreprocessorPlugin(on, config);
7+
8+
on("file:preprocessor", browserify.default(config));
9+
10+
// Make sure to return the config object as it might have been modified by the plugin.
11+
return config;
12+
}
13+
14+
module.exports = defineConfig({
15+
e2e: {
16+
specPattern: "**/*.feature",
17+
supportFile: false,
18+
setupNodeEvents,
19+
},
20+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Feature: duckduckgo.com
2+
Scenario: visting the frontpage
3+
When I visit duckduckgo.com
4+
Then I should see a search bar
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const { When, Then } = require("@badeball/cypress-cucumber-preprocessor");
2+
3+
When("I visit duckduckgo.com", () => {
4+
cy.visit("https://duckduckgo.com/");
5+
});
6+
7+
Then("I should see a search bar", () => {
8+
cy.get("input").should(
9+
"have.attr",
10+
"placeholder",
11+
"Search the web without being tracked"
12+
);
13+
14+
assert.deepEqual({}, {});
15+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": {
3+
"@badeball/cypress-cucumber-preprocessor": "latest",
4+
"@cypress/browserify-preprocessor": "latest",
5+
"cypress": "latest"
6+
}
7+
}

examples/esbuild-cjs/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const { defineConfig } = require("cypress");
2+
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
3+
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
4+
const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild");
5+
6+
async function setupNodeEvents(on, config) {
7+
await preprocessor.addCucumberPreprocessorPlugin(on, config);
8+
9+
on(
10+
"file:preprocessor",
11+
createBundler({
12+
plugins: [createEsbuildPlugin.default(config)],
13+
})
14+
);
15+
16+
// Make sure to return the config object as it might have been modified by the plugin.
17+
return config;
18+
}
19+
20+
module.exports = defineConfig({
21+
e2e: {
22+
specPattern: "**/*.feature",
23+
supportFile: false,
24+
setupNodeEvents,
25+
},
26+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Feature: duckduckgo.com
2+
Scenario: visting the frontpage
3+
When I visit duckduckgo.com
4+
Then I should see a search bar

0 commit comments

Comments
 (0)