Skip to content

Commit 1a9d097

Browse files
committed
Add examples in mjs
1 parent 17eb834 commit 1a9d097

File tree

17 files changed

+272
-0
lines changed

17 files changed

+272
-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-esm:
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-esm)
35+
rm -rf !(examples)
36+
- name: Install NPM modules
37+
working-directory: examples/browserify-esm
38+
run: npm install
39+
- name: Run Cypress
40+
working-directory: examples/browserify-esm
41+
run: npx cypress run
42+
1343
browserify-ts:
1444
runs-on: ubuntu-20.04
1545
container:
@@ -40,6 +70,36 @@ jobs:
4070
working-directory: examples/browserify-ts
4171
run: npx cypress run
4272

73+
webpack-esm:
74+
runs-on: ubuntu-20.04
75+
container:
76+
image: cypress/base:17.3.0
77+
steps:
78+
- name: Checkout
79+
uses: actions/checkout@v2
80+
- name: Cache NPM modules
81+
uses: actions/cache@v2
82+
with:
83+
path: ~/.npm
84+
key: npm
85+
- name: Cache Cypress binaries
86+
uses: actions/cache@v2
87+
with:
88+
path: ~/.cache/Cypress
89+
key: cypress
90+
# In lack of native support, https://github.com/actions/checkout/issues/172.
91+
- name: Make checkout sparse
92+
run: |
93+
shopt -s extglob
94+
rm -rf examples/!(webpack-esm)
95+
rm -rf !(examples)
96+
- name: Install NPM modules
97+
working-directory: examples/webpack-esm
98+
run: npm install
99+
- name: Run Cypress
100+
working-directory: examples/webpack-esm
101+
run: npx cypress run
102+
43103
webpack-ts:
44104
runs-on: ubuntu-20.04
45105
container:
@@ -70,6 +130,36 @@ jobs:
70130
working-directory: examples/webpack-ts
71131
run: npx cypress run
72132

133+
esbuild-esm:
134+
runs-on: ubuntu-20.04
135+
container:
136+
image: cypress/base:17.3.0
137+
steps:
138+
- name: Checkout
139+
uses: actions/checkout@v2
140+
- name: Cache NPM modules
141+
uses: actions/cache@v2
142+
with:
143+
path: ~/.npm
144+
key: npm
145+
- name: Cache Cypress binaries
146+
uses: actions/cache@v2
147+
with:
148+
path: ~/.cache/Cypress
149+
key: cypress
150+
# In lack of native support, https://github.com/actions/checkout/issues/172.
151+
- name: Make checkout sparse
152+
run: |
153+
shopt -s extglob
154+
rm -rf examples/!(esbuild-esm)
155+
rm -rf !(examples)
156+
- name: Install NPM modules
157+
working-directory: examples/esbuild-esm
158+
run: npm install
159+
- name: Run Cypress
160+
working-directory: examples/esbuild-esm
161+
run: npx cypress run
162+
73163
esbuild-ts:
74164
runs-on: ubuntu-20.04
75165
container:

examples/browserify-esm/.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+
import { defineConfig } from "cypress";
2+
import preprocessor from "@badeball/cypress-cucumber-preprocessor";
3+
import browserify from "@badeball/cypress-cucumber-preprocessor/browserify.js";
4+
5+
export 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+
export default 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+
import { When, Then } from "@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-esm/.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+
import { defineConfig } from "cypress";
2+
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
3+
import preprocessor from "@badeball/cypress-cucumber-preprocessor";
4+
import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild.js";
5+
6+
export 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+
export default 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
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { When, Then } from "@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+
});

0 commit comments

Comments
 (0)