Skip to content

Commit

Permalink
test(e2e): add dummy e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Dec 13, 2023
1 parent 035f259 commit 208ed31
Show file tree
Hide file tree
Showing 7 changed files with 5,214 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: "npm"
node-version-file: package.json
- run: npm ci

e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cypress run
uses: cypress-io/github-action@v6
with:
project: ./e2e
start: npm start
35 changes: 35 additions & 0 deletions e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//

import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild";
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
import { defineConfig } from "cypress";

//

export default defineConfig({
e2e: {
baseUrl: "https://duckduckgo.com",
specPattern: "**/*.feature",
setupNodeEvents,
supportFile: false,
},
});

//

async function setupNodeEvents(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
) {
await addCucumberPreprocessorPlugin(on, config);

on(
"file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin(config)],
})
);

return config;
}
4 changes: 4 additions & 0 deletions e2e/features/duckduckgo.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Feature: duckduckgo.com
Scenario: visiting the frontpage
When I visit duckduckgo.com
Then I should see a search bar
16 changes: 16 additions & 0 deletions e2e/features/duckduckgo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Then, When } from "@badeball/cypress-cucumber-preprocessor";

When("I visit duckduckgo.com", () => {
cy.visit("https://duckduckgo.com/");
});

Then("I should see a search bar", () => {
cy.get("input[type=text]")
.should("have.attr", "placeholder")
.and(
"match",
/Search the web without being tracked|Search without being tracked/
);

assert.deepEqual({}, {});
});
Loading

0 comments on commit 208ed31

Please sign in to comment.