test(web): feature Gherkin jetable pour valider le pipeline preprocessor
Étape 2 de l'expérimentation — un seul scénario minimal (remplir email/password sur l'écran de connexion) pour vérifier que addCucumberPreprocessorPlugin@22.2.0 + l'esbuild plugin fonctionnent de bout en bout, pas juste au chargement. Steps volontairement autonomes dans login-smoke.steps.ts (pas de fichier partagé) — tout ce fichier est prévu pour être supprimé une fois validé. cypress.config.ts : specPattern couvre maintenant *.cy.ts ET *.feature en parallèle (le reste de la suite reste en .cy.ts classique pour l'instant). Testé en local jusqu'au mur GPU/Electron habituel de cet environnement (chargement de la config + bundling esbuild passent, pas d'ERR_REQUIRE_ESM) — la vraie exécution du scénario reste à vérifier via la CI.
This commit is contained in:
parent
7a504748ac
commit
99bb9fcfb2
3 changed files with 53 additions and 1 deletions
|
|
@ -1,9 +1,18 @@
|
||||||
|
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";
|
import { defineConfig } from "cypress";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
baseUrl: "http://localhost:5173",
|
baseUrl: "http://localhost:5173",
|
||||||
setupNodeEvents(on) {
|
// Experimental — testing whether real Gherkin .feature files work with
|
||||||
|
// this preprocessor version (see experiment/cucumber-cypress). Only one
|
||||||
|
// throwaway feature exists right now (login.feature); the rest of the
|
||||||
|
// suite is still plain .cy.ts, matched by the default `**/*.cy.ts`
|
||||||
|
// pattern alongside `**/*.feature`.
|
||||||
|
specPattern: ["cypress/e2e/**/*.cy.ts", "cypress/e2e/**/*.feature"],
|
||||||
|
async setupNodeEvents(on, config) {
|
||||||
// Disable GPU for headless/sandboxed environments (e.g. CI containers)
|
// Disable GPU for headless/sandboxed environments (e.g. CI containers)
|
||||||
// where no GPU device is available.
|
// where no GPU device is available.
|
||||||
on("before:browser:launch", (browser, launchOptions) => {
|
on("before:browser:launch", (browser, launchOptions) => {
|
||||||
|
|
@ -12,6 +21,16 @@ export default defineConfig({
|
||||||
}
|
}
|
||||||
return launchOptions;
|
return launchOptions;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await addCucumberPreprocessorPlugin(on, config);
|
||||||
|
on(
|
||||||
|
"file:preprocessor",
|
||||||
|
createBundler({
|
||||||
|
plugins: [createEsbuildPlugin(config)],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return config;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
12
apps/web/cypress/e2e/login-smoke.feature
Normal file
12
apps/web/cypress/e2e/login-smoke.feature
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
Feature: Login screen (throwaway smoke test)
|
||||||
|
Just checking that Gherkin + Cypress actually work end to end with the
|
||||||
|
currently installed preprocessor version — not meant to stay in the
|
||||||
|
suite long-term.
|
||||||
|
|
||||||
|
Scenario: A visitor can type their credentials into the login screen
|
||||||
|
Given I am not signed in
|
||||||
|
When I visit "/login"
|
||||||
|
And I fill in the "email" field with "alice@example.com"
|
||||||
|
And I fill in the "password" field with "correct-horse-battery-staple"
|
||||||
|
Then the "email" field should have the value "alice@example.com"
|
||||||
|
And the "password" field should have the value "correct-horse-battery-staple"
|
||||||
21
apps/web/cypress/e2e/login-smoke.steps.ts
Normal file
21
apps/web/cypress/e2e/login-smoke.steps.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor";
|
||||||
|
|
||||||
|
// Throwaway smoke test — see login-smoke.feature. Steps are deliberately
|
||||||
|
// minimal/self-contained here rather than shared, since this whole file is
|
||||||
|
// meant to be deleted once it's proven the preprocessor works.
|
||||||
|
|
||||||
|
Given("I am not signed in", () => {
|
||||||
|
cy.intercept("GET", "**/auth/me", { statusCode: 401 });
|
||||||
|
});
|
||||||
|
|
||||||
|
When("I visit {string}", (path: string) => {
|
||||||
|
cy.visit(path);
|
||||||
|
});
|
||||||
|
|
||||||
|
When("I fill in the {string} field with {string}", (fieldId: string, value: string) => {
|
||||||
|
cy.get(`#${fieldId}`).type(value);
|
||||||
|
});
|
||||||
|
|
||||||
|
Then("the {string} field should have the value {string}", (fieldId: string, value: string) => {
|
||||||
|
cy.get(`#${fieldId}`).should("have.value", value);
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue