racejar 1.2.14 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/compile-feature.cjs +101 -0
- package/dist/_chunks-cjs/compile-feature.cjs.map +1 -0
- package/dist/_chunks-dts/step-definitions.d.cts +44 -0
- package/dist/_chunks-dts/step-definitions.d.ts +44 -0
- package/dist/_chunks-es/compile-feature.js +88 -0
- package/dist/_chunks-es/compile-feature.js.map +1 -0
- package/dist/index.cjs +36 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +44 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/jest/index.cjs +29 -0
- package/dist/jest/index.cjs.map +1 -0
- package/dist/jest/index.d.cts +17 -0
- package/dist/jest/index.d.ts +17 -0
- package/dist/jest/index.js +30 -0
- package/dist/jest/index.js.map +1 -0
- package/dist/playwright/index.cjs +39 -0
- package/dist/playwright/index.cjs.map +1 -0
- package/dist/playwright/index.d.cts +25 -0
- package/dist/playwright/index.d.ts +25 -0
- package/dist/playwright/index.js +40 -0
- package/dist/playwright/index.js.map +1 -0
- package/dist/vitest/index.cjs +29 -0
- package/dist/vitest/index.cjs.map +1 -0
- package/dist/vitest/index.d.cts +17 -0
- package/dist/vitest/index.d.ts +17 -0
- package/dist/vitest/index.js +30 -0
- package/dist/vitest/index.js.map +1 -0
- package/package.json +39 -16
- package/src/compile-feature.ts +3 -3
- package/CHANGELOG.md +0 -150
- package/example/vitest.hello-herman.test.ts +0 -37
- package/example/vitest.hooks.test.ts +0 -49
- package/example-playwright/playwright-homepage.test.ts +0 -35
- package/tsconfig.json +0 -7
- package/vitest.config.ts +0 -15
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var test = require("@playwright/test"), compileFeature = require("../_chunks-cjs/compile-feature.cjs");
|
|
4
|
+
function Feature({
|
|
5
|
+
featureText,
|
|
6
|
+
hooks,
|
|
7
|
+
stepDefinitions,
|
|
8
|
+
parameterTypes
|
|
9
|
+
}) {
|
|
10
|
+
const feature = compileFeature.compileFeature({
|
|
11
|
+
featureText,
|
|
12
|
+
hooks: hooks ?? [],
|
|
13
|
+
stepDefinitions,
|
|
14
|
+
parameterTypes: parameterTypes ?? []
|
|
15
|
+
});
|
|
16
|
+
(feature.tag === "only" ? test.test.describe.only : feature.tag === "skip" ? test.test.describe.skip : test.test.describe)(feature.name, () => {
|
|
17
|
+
for (const before of feature.beforeHooks)
|
|
18
|
+
test.test.beforeEach(async (playwrightOptions) => {
|
|
19
|
+
await before({
|
|
20
|
+
playwright: playwrightOptions
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
for (const after of feature.afterHooks)
|
|
24
|
+
test.test.afterEach(async (playwrightOptions) => {
|
|
25
|
+
await after({
|
|
26
|
+
playwright: playwrightOptions
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
for (const scenario of feature.scenarios)
|
|
30
|
+
(scenario.tag === "only" ? test.test.only : scenario.tag === "skip" ? test.test.skip : test.test)(scenario.name, async (playwrightOptions) => {
|
|
31
|
+
for (const step of scenario.steps)
|
|
32
|
+
await step({
|
|
33
|
+
playwright: playwrightOptions
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.Feature = Feature;
|
|
39
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/playwright/playwright-gherkin-driver.ts"],"sourcesContent":["import type {ParameterType} from '@cucumber/cucumber-expressions'\nimport {\n test,\n type PlaywrightTestArgs,\n type PlaywrightTestOptions,\n type PlaywrightWorkerArgs,\n type PlaywrightWorkerOptions,\n} from '@playwright/test'\nimport {compileFeature} from '../compile-feature'\nimport type {Hook} from '../hooks'\nimport type {StepDefinition} from '../step-definitions'\n\ntype PlaywrightOptions = PlaywrightTestArgs &\n PlaywrightTestOptions &\n PlaywrightWorkerArgs &\n PlaywrightWorkerOptions\n\n/**\n * @public\n */\nexport type PlaywrightContext = Record<'string', any> & {\n playwright: PlaywrightOptions\n}\n\n/**\n * @public\n */\nexport function Feature<\n TContext extends PlaywrightContext = PlaywrightContext,\n>({\n featureText,\n hooks,\n stepDefinitions,\n parameterTypes,\n}: {\n featureText: string\n hooks?: Array<Hook<TContext>>\n stepDefinitions: Array<StepDefinition<TContext, any, any, any>>\n parameterTypes?: Array<ParameterType<unknown>>\n}) {\n const feature = compileFeature({\n featureText,\n hooks: hooks ?? [],\n stepDefinitions,\n parameterTypes: parameterTypes ?? [],\n })\n\n const describeFn =\n feature.tag === 'only'\n ? test.describe.only\n : feature.tag === 'skip'\n ? test.describe.skip\n : test.describe\n\n describeFn(feature.name, () => {\n for (const before of feature.beforeHooks) {\n test.beforeEach(async (playwrightOptions) => {\n await before({\n playwright: playwrightOptions,\n } as TContext)\n })\n }\n\n for (const after of feature.afterHooks) {\n test.afterEach(async (playwrightOptions) => {\n await after({\n playwright: playwrightOptions,\n } as TContext)\n })\n }\n\n for (const scenario of feature.scenarios) {\n const testFn =\n scenario.tag === 'only'\n ? test.only\n : scenario.tag === 'skip'\n ? test.skip\n : test\n\n testFn(scenario.name, async (playwrightOptions) => {\n for (const step of scenario.steps) {\n await step({\n playwright: playwrightOptions,\n } as TContext)\n }\n })\n }\n })\n}\n"],"names":["compileFeature","test"],"mappings":";;;AA2BO,SAAS,QAEd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,UAAUA,eAAAA,eAAe;AAAA,IAC7B;AAAA,IACA,OAAO,SAAS,CAAA;AAAA,IAChB;AAAA,IACA,gBAAgB,kBAAkB,CAAA;AAAA,EAAC,CACpC;AASD,GANE,QAAQ,QAAQ,SACZC,KAAAA,KAAK,SAAS,OACd,QAAQ,QAAQ,SACdA,KAAAA,KAAK,SAAS,OACdA,KAAAA,KAAK,UAEF,QAAQ,MAAM,MAAM;AAC7B,eAAW,UAAU,QAAQ;AAC3BA,gBAAK,WAAW,OAAO,sBAAsB;AAC3C,cAAM,OAAO;AAAA,UACX,YAAY;AAAA,QAAA,CACD;AAAA,MACf,CAAC;AAGH,eAAW,SAAS,QAAQ;AAC1BA,gBAAK,UAAU,OAAO,sBAAsB;AAC1C,cAAM,MAAM;AAAA,UACV,YAAY;AAAA,QAAA,CACD;AAAA,MACf,CAAC;AAGH,eAAW,YAAY,QAAQ;AAQ7B,OANE,SAAS,QAAQ,SACbA,KAAAA,KAAK,OACL,SAAS,QAAQ,SACfA,KAAAA,KAAK,OACLA,KAAAA,MAED,SAAS,MAAM,OAAO,sBAAsB;AACjD,mBAAW,QAAQ,SAAS;AAC1B,gBAAM,KAAK;AAAA,YACT,YAAY;AAAA,UAAA,CACD;AAAA,MAEjB,CAAC;AAAA,EAEL,CAAC;AACH;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Hook, StepDefinition } from "../_chunks-dts/step-definitions.cjs";
|
|
2
|
+
import { ParameterType } from "@cucumber/cucumber-expressions";
|
|
3
|
+
import { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from "@playwright/test";
|
|
4
|
+
type PlaywrightOptions = PlaywrightTestArgs & PlaywrightTestOptions & PlaywrightWorkerArgs & PlaywrightWorkerOptions;
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
type PlaywrightContext = Record<'string', any> & {
|
|
9
|
+
playwright: PlaywrightOptions;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
declare function Feature<TContext extends PlaywrightContext = PlaywrightContext>({
|
|
15
|
+
featureText,
|
|
16
|
+
hooks,
|
|
17
|
+
stepDefinitions,
|
|
18
|
+
parameterTypes
|
|
19
|
+
}: {
|
|
20
|
+
featureText: string;
|
|
21
|
+
hooks?: Array<Hook<TContext>>;
|
|
22
|
+
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>;
|
|
23
|
+
parameterTypes?: Array<ParameterType<unknown>>;
|
|
24
|
+
}): void;
|
|
25
|
+
export { Feature, PlaywrightContext };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Hook, StepDefinition } from "../_chunks-dts/step-definitions.js";
|
|
2
|
+
import { ParameterType } from "@cucumber/cucumber-expressions";
|
|
3
|
+
import { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from "@playwright/test";
|
|
4
|
+
type PlaywrightOptions = PlaywrightTestArgs & PlaywrightTestOptions & PlaywrightWorkerArgs & PlaywrightWorkerOptions;
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
type PlaywrightContext = Record<'string', any> & {
|
|
9
|
+
playwright: PlaywrightOptions;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
declare function Feature<TContext extends PlaywrightContext = PlaywrightContext>({
|
|
15
|
+
featureText,
|
|
16
|
+
hooks,
|
|
17
|
+
stepDefinitions,
|
|
18
|
+
parameterTypes
|
|
19
|
+
}: {
|
|
20
|
+
featureText: string;
|
|
21
|
+
hooks?: Array<Hook<TContext>>;
|
|
22
|
+
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>;
|
|
23
|
+
parameterTypes?: Array<ParameterType<unknown>>;
|
|
24
|
+
}): void;
|
|
25
|
+
export { Feature, PlaywrightContext };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { test } from "@playwright/test";
|
|
2
|
+
import { compileFeature } from "../_chunks-es/compile-feature.js";
|
|
3
|
+
function Feature({
|
|
4
|
+
featureText,
|
|
5
|
+
hooks,
|
|
6
|
+
stepDefinitions,
|
|
7
|
+
parameterTypes
|
|
8
|
+
}) {
|
|
9
|
+
const feature = compileFeature({
|
|
10
|
+
featureText,
|
|
11
|
+
hooks: hooks ?? [],
|
|
12
|
+
stepDefinitions,
|
|
13
|
+
parameterTypes: parameterTypes ?? []
|
|
14
|
+
});
|
|
15
|
+
(feature.tag === "only" ? test.describe.only : feature.tag === "skip" ? test.describe.skip : test.describe)(feature.name, () => {
|
|
16
|
+
for (const before of feature.beforeHooks)
|
|
17
|
+
test.beforeEach(async (playwrightOptions) => {
|
|
18
|
+
await before({
|
|
19
|
+
playwright: playwrightOptions
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
for (const after of feature.afterHooks)
|
|
23
|
+
test.afterEach(async (playwrightOptions) => {
|
|
24
|
+
await after({
|
|
25
|
+
playwright: playwrightOptions
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
for (const scenario of feature.scenarios)
|
|
29
|
+
(scenario.tag === "only" ? test.only : scenario.tag === "skip" ? test.skip : test)(scenario.name, async (playwrightOptions) => {
|
|
30
|
+
for (const step of scenario.steps)
|
|
31
|
+
await step({
|
|
32
|
+
playwright: playwrightOptions
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
Feature
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/playwright/playwright-gherkin-driver.ts"],"sourcesContent":["import type {ParameterType} from '@cucumber/cucumber-expressions'\nimport {\n test,\n type PlaywrightTestArgs,\n type PlaywrightTestOptions,\n type PlaywrightWorkerArgs,\n type PlaywrightWorkerOptions,\n} from '@playwright/test'\nimport {compileFeature} from '../compile-feature'\nimport type {Hook} from '../hooks'\nimport type {StepDefinition} from '../step-definitions'\n\ntype PlaywrightOptions = PlaywrightTestArgs &\n PlaywrightTestOptions &\n PlaywrightWorkerArgs &\n PlaywrightWorkerOptions\n\n/**\n * @public\n */\nexport type PlaywrightContext = Record<'string', any> & {\n playwright: PlaywrightOptions\n}\n\n/**\n * @public\n */\nexport function Feature<\n TContext extends PlaywrightContext = PlaywrightContext,\n>({\n featureText,\n hooks,\n stepDefinitions,\n parameterTypes,\n}: {\n featureText: string\n hooks?: Array<Hook<TContext>>\n stepDefinitions: Array<StepDefinition<TContext, any, any, any>>\n parameterTypes?: Array<ParameterType<unknown>>\n}) {\n const feature = compileFeature({\n featureText,\n hooks: hooks ?? [],\n stepDefinitions,\n parameterTypes: parameterTypes ?? [],\n })\n\n const describeFn =\n feature.tag === 'only'\n ? test.describe.only\n : feature.tag === 'skip'\n ? test.describe.skip\n : test.describe\n\n describeFn(feature.name, () => {\n for (const before of feature.beforeHooks) {\n test.beforeEach(async (playwrightOptions) => {\n await before({\n playwright: playwrightOptions,\n } as TContext)\n })\n }\n\n for (const after of feature.afterHooks) {\n test.afterEach(async (playwrightOptions) => {\n await after({\n playwright: playwrightOptions,\n } as TContext)\n })\n }\n\n for (const scenario of feature.scenarios) {\n const testFn =\n scenario.tag === 'only'\n ? test.only\n : scenario.tag === 'skip'\n ? test.skip\n : test\n\n testFn(scenario.name, async (playwrightOptions) => {\n for (const step of scenario.steps) {\n await step({\n playwright: playwrightOptions,\n } as TContext)\n }\n })\n }\n })\n}\n"],"names":[],"mappings":";;AA2BO,SAAS,QAEd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,UAAU,eAAe;AAAA,IAC7B;AAAA,IACA,OAAO,SAAS,CAAA;AAAA,IAChB;AAAA,IACA,gBAAgB,kBAAkB,CAAA;AAAA,EAAC,CACpC;AASD,GANE,QAAQ,QAAQ,SACZ,KAAK,SAAS,OACd,QAAQ,QAAQ,SACd,KAAK,SAAS,OACd,KAAK,UAEF,QAAQ,MAAM,MAAM;AAC7B,eAAW,UAAU,QAAQ;AAC3B,WAAK,WAAW,OAAO,sBAAsB;AAC3C,cAAM,OAAO;AAAA,UACX,YAAY;AAAA,QAAA,CACD;AAAA,MACf,CAAC;AAGH,eAAW,SAAS,QAAQ;AAC1B,WAAK,UAAU,OAAO,sBAAsB;AAC1C,cAAM,MAAM;AAAA,UACV,YAAY;AAAA,QAAA,CACD;AAAA,MACf,CAAC;AAGH,eAAW,YAAY,QAAQ;AAQ7B,OANE,SAAS,QAAQ,SACb,KAAK,OACL,SAAS,QAAQ,SACf,KAAK,OACL,MAED,SAAS,MAAM,OAAO,sBAAsB;AACjD,mBAAW,QAAQ,SAAS;AAC1B,gBAAM,KAAK;AAAA,YACT,YAAY;AAAA,UAAA,CACD;AAAA,MAEjB,CAAC;AAAA,EAEL,CAAC;AACH;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var vitest = require("vitest"), compileFeature = require("../_chunks-cjs/compile-feature.cjs");
|
|
4
|
+
function Feature({
|
|
5
|
+
featureText,
|
|
6
|
+
hooks,
|
|
7
|
+
stepDefinitions,
|
|
8
|
+
parameterTypes
|
|
9
|
+
}) {
|
|
10
|
+
const feature = compileFeature.compileFeature({
|
|
11
|
+
featureText,
|
|
12
|
+
hooks: hooks ?? [],
|
|
13
|
+
stepDefinitions,
|
|
14
|
+
parameterTypes: parameterTypes ?? []
|
|
15
|
+
});
|
|
16
|
+
(feature.tag === "only" ? vitest.describe.only : feature.tag === "skip" ? vitest.describe.skip : vitest.describe)(feature.name, () => {
|
|
17
|
+
for (const before of feature.beforeHooks)
|
|
18
|
+
vitest.beforeEach(before);
|
|
19
|
+
for (const after of feature.afterHooks)
|
|
20
|
+
vitest.afterEach(after);
|
|
21
|
+
for (const scenario of feature.scenarios)
|
|
22
|
+
(scenario.tag === "only" ? vitest.test.only : scenario.tag === "skip" ? vitest.test.skip : vitest.test)(scenario.name, async () => {
|
|
23
|
+
for (const step of scenario.steps)
|
|
24
|
+
await step();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.Feature = Feature;
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/vitest/vitest-gherkin-driver.ts"],"sourcesContent":["import type {ParameterType} from '@cucumber/cucumber-expressions'\nimport {afterEach, beforeEach, describe, test} from 'vitest'\nimport {compileFeature} from '../compile-feature'\nimport type {Hook} from '../hooks'\nimport type {StepDefinition} from '../step-definitions'\n\n/**\n * @public\n */\nexport function Feature<TContext extends Record<string, any> = object>({\n featureText,\n hooks,\n stepDefinitions,\n parameterTypes,\n}: {\n featureText: string\n hooks?: Array<Hook<TContext>>\n stepDefinitions: Array<StepDefinition<TContext, any, any, any>>\n parameterTypes?: Array<ParameterType<unknown>>\n}) {\n const feature = compileFeature({\n featureText,\n hooks: hooks ?? [],\n stepDefinitions,\n parameterTypes: parameterTypes ?? [],\n })\n\n const describeFn =\n feature.tag === 'only'\n ? describe.only\n : feature.tag === 'skip'\n ? describe.skip\n : describe\n\n describeFn(feature.name, () => {\n for (const before of feature.beforeHooks) {\n beforeEach(before)\n }\n\n for (const after of feature.afterHooks) {\n afterEach(after)\n }\n\n for (const scenario of feature.scenarios) {\n const testFn =\n scenario.tag === 'only'\n ? test.only\n : scenario.tag === 'skip'\n ? test.skip\n : test\n\n testFn(scenario.name, async () => {\n for (const step of scenario.steps) {\n await step()\n }\n })\n }\n })\n}\n"],"names":["compileFeature","describe","beforeEach","afterEach","test"],"mappings":";;;AASO,SAAS,QAAuD;AAAA,EACrE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,UAAUA,eAAAA,eAAe;AAAA,IAC7B;AAAA,IACA,OAAO,SAAS,CAAA;AAAA,IAChB;AAAA,IACA,gBAAgB,kBAAkB,CAAA;AAAA,EAAC,CACpC;AASD,GANE,QAAQ,QAAQ,SACZC,OAAAA,SAAS,OACT,QAAQ,QAAQ,SACdA,OAAAA,SAAS,OACTA,OAAAA,UAEG,QAAQ,MAAM,MAAM;AAC7B,eAAW,UAAU,QAAQ;AAC3BC,aAAAA,WAAW,MAAM;AAGnB,eAAW,SAAS,QAAQ;AAC1BC,aAAAA,UAAU,KAAK;AAGjB,eAAW,YAAY,QAAQ;AAQ7B,OANE,SAAS,QAAQ,SACbC,OAAAA,KAAK,OACL,SAAS,QAAQ,SACfA,OAAAA,KAAK,OACLA,OAAAA,MAED,SAAS,MAAM,YAAY;AAChC,mBAAW,QAAQ,SAAS;AAC1B,gBAAM,KAAA;AAAA,MAEV,CAAC;AAAA,EAEL,CAAC;AACH;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Hook, StepDefinition } from "../_chunks-dts/step-definitions.cjs";
|
|
2
|
+
import { ParameterType } from "@cucumber/cucumber-expressions";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
declare function Feature<TContext extends Record<string, any> = object>({
|
|
7
|
+
featureText,
|
|
8
|
+
hooks,
|
|
9
|
+
stepDefinitions,
|
|
10
|
+
parameterTypes
|
|
11
|
+
}: {
|
|
12
|
+
featureText: string;
|
|
13
|
+
hooks?: Array<Hook<TContext>>;
|
|
14
|
+
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>;
|
|
15
|
+
parameterTypes?: Array<ParameterType<unknown>>;
|
|
16
|
+
}): void;
|
|
17
|
+
export { Feature };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Hook, StepDefinition } from "../_chunks-dts/step-definitions.js";
|
|
2
|
+
import { ParameterType } from "@cucumber/cucumber-expressions";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
declare function Feature<TContext extends Record<string, any> = object>({
|
|
7
|
+
featureText,
|
|
8
|
+
hooks,
|
|
9
|
+
stepDefinitions,
|
|
10
|
+
parameterTypes
|
|
11
|
+
}: {
|
|
12
|
+
featureText: string;
|
|
13
|
+
hooks?: Array<Hook<TContext>>;
|
|
14
|
+
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>;
|
|
15
|
+
parameterTypes?: Array<ParameterType<unknown>>;
|
|
16
|
+
}): void;
|
|
17
|
+
export { Feature };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, beforeEach, afterEach, test } from "vitest";
|
|
2
|
+
import { compileFeature } from "../_chunks-es/compile-feature.js";
|
|
3
|
+
function Feature({
|
|
4
|
+
featureText,
|
|
5
|
+
hooks,
|
|
6
|
+
stepDefinitions,
|
|
7
|
+
parameterTypes
|
|
8
|
+
}) {
|
|
9
|
+
const feature = compileFeature({
|
|
10
|
+
featureText,
|
|
11
|
+
hooks: hooks ?? [],
|
|
12
|
+
stepDefinitions,
|
|
13
|
+
parameterTypes: parameterTypes ?? []
|
|
14
|
+
});
|
|
15
|
+
(feature.tag === "only" ? describe.only : feature.tag === "skip" ? describe.skip : describe)(feature.name, () => {
|
|
16
|
+
for (const before of feature.beforeHooks)
|
|
17
|
+
beforeEach(before);
|
|
18
|
+
for (const after of feature.afterHooks)
|
|
19
|
+
afterEach(after);
|
|
20
|
+
for (const scenario of feature.scenarios)
|
|
21
|
+
(scenario.tag === "only" ? test.only : scenario.tag === "skip" ? test.skip : test)(scenario.name, async () => {
|
|
22
|
+
for (const step of scenario.steps)
|
|
23
|
+
await step();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
Feature
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/vitest/vitest-gherkin-driver.ts"],"sourcesContent":["import type {ParameterType} from '@cucumber/cucumber-expressions'\nimport {afterEach, beforeEach, describe, test} from 'vitest'\nimport {compileFeature} from '../compile-feature'\nimport type {Hook} from '../hooks'\nimport type {StepDefinition} from '../step-definitions'\n\n/**\n * @public\n */\nexport function Feature<TContext extends Record<string, any> = object>({\n featureText,\n hooks,\n stepDefinitions,\n parameterTypes,\n}: {\n featureText: string\n hooks?: Array<Hook<TContext>>\n stepDefinitions: Array<StepDefinition<TContext, any, any, any>>\n parameterTypes?: Array<ParameterType<unknown>>\n}) {\n const feature = compileFeature({\n featureText,\n hooks: hooks ?? [],\n stepDefinitions,\n parameterTypes: parameterTypes ?? [],\n })\n\n const describeFn =\n feature.tag === 'only'\n ? describe.only\n : feature.tag === 'skip'\n ? describe.skip\n : describe\n\n describeFn(feature.name, () => {\n for (const before of feature.beforeHooks) {\n beforeEach(before)\n }\n\n for (const after of feature.afterHooks) {\n afterEach(after)\n }\n\n for (const scenario of feature.scenarios) {\n const testFn =\n scenario.tag === 'only'\n ? test.only\n : scenario.tag === 'skip'\n ? test.skip\n : test\n\n testFn(scenario.name, async () => {\n for (const step of scenario.steps) {\n await step()\n }\n })\n }\n })\n}\n"],"names":[],"mappings":";;AASO,SAAS,QAAuD;AAAA,EACrE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,UAAU,eAAe;AAAA,IAC7B;AAAA,IACA,OAAO,SAAS,CAAA;AAAA,IAChB;AAAA,IACA,gBAAgB,kBAAkB,CAAA;AAAA,EAAC,CACpC;AASD,GANE,QAAQ,QAAQ,SACZ,SAAS,OACT,QAAQ,QAAQ,SACd,SAAS,OACT,UAEG,QAAQ,MAAM,MAAM;AAC7B,eAAW,UAAU,QAAQ;AAC3B,iBAAW,MAAM;AAGnB,eAAW,SAAS,QAAQ;AAC1B,gBAAU,KAAK;AAGjB,eAAW,YAAY,QAAQ;AAQ7B,OANE,SAAS,QAAQ,SACb,KAAK,OACL,SAAS,QAAQ,SACf,KAAK,OACL,MAED,SAAS,MAAM,YAAY;AAChC,mBAAW,QAAQ,SAAS;AAC1B,gBAAM,KAAA;AAAA,MAEV,CAAC;AAAA,EAEL,CAAC;AACH;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "racejar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A testing framework agnostic Gherkin driver",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cucumber",
|
|
@@ -21,42 +21,65 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "Sanity.io <hello@sanity.io>",
|
|
23
23
|
"sideEffects": false,
|
|
24
|
+
"type": "module",
|
|
24
25
|
"exports": {
|
|
25
26
|
".": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
27
|
+
"source": "./src/index.ts",
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"require": "./dist/index.cjs",
|
|
30
|
+
"default": "./dist/index.js"
|
|
28
31
|
},
|
|
29
32
|
"./jest": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
33
|
+
"source": "./src/jest/index.ts",
|
|
34
|
+
"import": "./dist/jest/index.js",
|
|
35
|
+
"require": "./dist/jest/index.cjs",
|
|
36
|
+
"default": "./dist/jest/index.js"
|
|
32
37
|
},
|
|
33
38
|
"./playwright": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
39
|
+
"source": "./src/playwright/index.ts",
|
|
40
|
+
"import": "./dist/playwright/index.js",
|
|
41
|
+
"require": "./dist/playwright/index.cjs",
|
|
42
|
+
"default": "./dist/playwright/index.js"
|
|
36
43
|
},
|
|
37
44
|
"./vitest": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
45
|
+
"source": "./src/vitest/index.ts",
|
|
46
|
+
"import": "./dist/vitest/index.js",
|
|
47
|
+
"require": "./dist/vitest/index.cjs",
|
|
48
|
+
"default": "./dist/vitest/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./package.json": "./package.json"
|
|
41
51
|
},
|
|
42
|
-
"
|
|
52
|
+
"main": "./dist/index.cjs",
|
|
53
|
+
"module": "./dist/index.js",
|
|
54
|
+
"types": "./dist/index.d.ts",
|
|
55
|
+
"files": [
|
|
56
|
+
"dist",
|
|
57
|
+
"src"
|
|
58
|
+
],
|
|
59
|
+
"dependencies": {
|
|
43
60
|
"@cucumber/cucumber-expressions": "^18.0.1",
|
|
44
|
-
"@cucumber/gherkin": "^
|
|
45
|
-
"@cucumber/messages": "^
|
|
46
|
-
|
|
61
|
+
"@cucumber/gherkin": "^35.0.0",
|
|
62
|
+
"@cucumber/messages": "^29.0.1"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@jest/globals": "^30.1.2",
|
|
47
66
|
"@playwright/test": "^1.55.0",
|
|
48
|
-
"@sanity/pkg-utils": "^
|
|
67
|
+
"@sanity/pkg-utils": "^8.1.4",
|
|
49
68
|
"typescript": "5.9.2",
|
|
50
69
|
"vitest": "^3.2.4"
|
|
51
70
|
},
|
|
52
71
|
"peerDependencies": {
|
|
53
|
-
"@jest/globals": "^30.
|
|
72
|
+
"@jest/globals": "^30.1.2",
|
|
54
73
|
"@playwright/test": "^1.55.0",
|
|
55
74
|
"vitest": "^3.2.4"
|
|
56
75
|
},
|
|
57
76
|
"scripts": {
|
|
77
|
+
"build": "pkg-utils build --strict --check --clean",
|
|
58
78
|
"check:lint": "biome lint .",
|
|
59
79
|
"check:types": "tsc",
|
|
80
|
+
"check:types:watch": "tsc --watch",
|
|
81
|
+
"clean": "del .turbo && del dist && del node_modules",
|
|
82
|
+
"dev": "pkg-utils watch",
|
|
60
83
|
"lint:fix": "biome lint --write .",
|
|
61
84
|
"test": "vitest --run",
|
|
62
85
|
"test:watch": "vitest"
|
package/src/compile-feature.ts
CHANGED
|
@@ -55,9 +55,9 @@ export function compileFeature<
|
|
|
55
55
|
|
|
56
56
|
const parameterTypeRegistry = new ParameterTypeRegistry()
|
|
57
57
|
if (parameterTypes) {
|
|
58
|
-
parameterTypes.forEach((parameterType) =>
|
|
59
|
-
parameterTypeRegistry.defineParameterType(parameterType)
|
|
60
|
-
)
|
|
58
|
+
parameterTypes.forEach((parameterType) => {
|
|
59
|
+
parameterTypeRegistry.defineParameterType(parameterType)
|
|
60
|
+
})
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (!gherkinDocument.feature) {
|
package/CHANGELOG.md
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 1.2.14
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [#1545](https://github.com/portabletext/editor/pull/1545) [`c2b3a21`](https://github.com/portabletext/editor/commit/c2b3a216d12dc7c35df80bf04daedf6e5c27021b) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency @playwright/test to ^1.55.0
|
|
8
|
-
|
|
9
|
-
## 1.2.13
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- [#1542](https://github.com/portabletext/editor/pull/1542) [`7f1d5a2`](https://github.com/portabletext/editor/commit/7f1d5a2e7576e51cba249721e9279d1b42f8bd99) Thanks [@stipsan](https://github.com/stipsan)! - Update LICENSE year from 2024 to 2025
|
|
14
|
-
|
|
15
|
-
## [1.2.12](https://github.com/portabletext/editor/compare/racejar-v1.2.11...racejar-v1.2.12) (2025-08-04)
|
|
16
|
-
|
|
17
|
-
### Bug Fixes
|
|
18
|
-
|
|
19
|
-
- **deps:** update dependency @playwright/test to ^1.54.2 ([42d2f5d](https://github.com/portabletext/editor/commit/42d2f5dc718a330656a5218d6073df63470a0716))
|
|
20
|
-
|
|
21
|
-
## [1.2.11](https://github.com/portabletext/editor/compare/racejar-v1.2.10...racejar-v1.2.11) (2025-08-04)
|
|
22
|
-
|
|
23
|
-
### Bug Fixes
|
|
24
|
-
|
|
25
|
-
- **deps:** update dependency @jest/globals to ^30.0.5 ([1c91c8f](https://github.com/portabletext/editor/commit/1c91c8fabda38d4ae553b5dfa11c38ebf6db9b1d))
|
|
26
|
-
|
|
27
|
-
## [1.2.10](https://github.com/portabletext/editor/compare/racejar-v1.2.9...racejar-v1.2.10) (2025-07-08)
|
|
28
|
-
|
|
29
|
-
### Bug Fixes
|
|
30
|
-
|
|
31
|
-
- **deps:** update dependency @jest/globals to ^30.0.4 ([38ff9dd](https://github.com/portabletext/editor/commit/38ff9dda2d7c5db3a11f1009e072ddab4d9c3d5c))
|
|
32
|
-
- **deps:** update dependency @playwright/test to ^1.53.2 ([237384f](https://github.com/portabletext/editor/commit/237384f4e1b184253a3566147aa5d84d33b26a98))
|
|
33
|
-
|
|
34
|
-
## [1.2.9](https://github.com/portabletext/editor/compare/racejar-v1.2.8...racejar-v1.2.9) (2025-06-25)
|
|
35
|
-
|
|
36
|
-
### Bug Fixes
|
|
37
|
-
|
|
38
|
-
- **deps:** update dependency @jest/globals to ^30.0.3 ([7ac18b1](https://github.com/portabletext/editor/commit/7ac18b10574b1641e923708ca9a30f96bb65ec6c))
|
|
39
|
-
|
|
40
|
-
## [1.2.8](https://github.com/portabletext/editor/compare/racejar-v1.2.7...racejar-v1.2.8) (2025-06-24)
|
|
41
|
-
|
|
42
|
-
### Bug Fixes
|
|
43
|
-
|
|
44
|
-
- **deps:** update dependency @jest/globals to ^30.0.2 ([59c86d7](https://github.com/portabletext/editor/commit/59c86d77adff8b8090c84ab70073e106348f4fc3))
|
|
45
|
-
|
|
46
|
-
## [1.2.7](https://github.com/portabletext/editor/compare/racejar-v1.2.6...racejar-v1.2.7) (2025-06-19)
|
|
47
|
-
|
|
48
|
-
### Bug Fixes
|
|
49
|
-
|
|
50
|
-
- **deps:** update dependency @jest/globals to ^30.0.1 ([92b9f3b](https://github.com/portabletext/editor/commit/92b9f3bb1aacf6f0ad7067991481eb40487ad281))
|
|
51
|
-
- **deps:** update dependency @playwright/test to ^1.53.1 ([9f846bd](https://github.com/portabletext/editor/commit/9f846bd7e6797ac493c6693ad2a74630b7f31bc4))
|
|
52
|
-
|
|
53
|
-
## [1.2.6](https://github.com/portabletext/editor/compare/racejar-v1.2.5...racejar-v1.2.6) (2025-06-12)
|
|
54
|
-
|
|
55
|
-
### Bug Fixes
|
|
56
|
-
|
|
57
|
-
- **deps:** update dependency @jest/globals to v30 ([3f92f15](https://github.com/portabletext/editor/commit/3f92f15fa399dbc19705bf0d680f53069333f355))
|
|
58
|
-
- **deps:** update dependency @playwright/test to ^1.53.0 ([6a0e159](https://github.com/portabletext/editor/commit/6a0e15902bce2d13abe011bbf4f70bff8b9573e7))
|
|
59
|
-
|
|
60
|
-
## [1.2.5](https://github.com/portabletext/editor/compare/racejar-v1.2.4...racejar-v1.2.5) (2025-05-14)
|
|
61
|
-
|
|
62
|
-
### Bug Fixes
|
|
63
|
-
|
|
64
|
-
- scope hooks to each Feature ([1f153ae](https://github.com/portabletext/editor/commit/1f153ae19b2509663a32a1a26838b4ece53226ff))
|
|
65
|
-
|
|
66
|
-
## [1.2.4](https://github.com/portabletext/editor/compare/racejar-v1.2.3...racejar-v1.2.4) (2025-04-19)
|
|
67
|
-
|
|
68
|
-
### Bug Fixes
|
|
69
|
-
|
|
70
|
-
- **deps:** update dependency @playwright/test to ^1.52.0 ([889ee63](https://github.com/portabletext/editor/commit/889ee638f0dccd473f361979fa6dfd1d8d3e216b))
|
|
71
|
-
|
|
72
|
-
## [1.2.3](https://github.com/portabletext/editor/compare/racejar-v1.2.2...racejar-v1.2.3) (2025-03-21)
|
|
73
|
-
|
|
74
|
-
### Bug Fixes
|
|
75
|
-
|
|
76
|
-
- **deps:** update dependency @playwright/test to ^1.51.1 ([eaa65eb](https://github.com/portabletext/editor/commit/eaa65eb8ae09bcbc2877e7f8d015b30be66c5f99))
|
|
77
|
-
|
|
78
|
-
## [1.2.2](https://github.com/portabletext/editor/compare/racejar-v1.2.1...racejar-v1.2.2) (2025-03-12)
|
|
79
|
-
|
|
80
|
-
### Bug Fixes
|
|
81
|
-
|
|
82
|
-
- **deps:** update dependency @playwright/test to ^1.51.0 ([38b00b7](https://github.com/portabletext/editor/commit/38b00b7e41b74a5075896e87e8ceac2a70c18a4b))
|
|
83
|
-
|
|
84
|
-
## [1.2.1](https://github.com/portabletext/editor/compare/racejar-v1.2.0...racejar-v1.2.1) (2025-03-03)
|
|
85
|
-
|
|
86
|
-
### Bug Fixes
|
|
87
|
-
|
|
88
|
-
- make hooks optional in Playwright Feature ([b02b7fd](https://github.com/portabletext/editor/commit/b02b7fd86c1ef77a4928f8997244b18c16972e9c))
|
|
89
|
-
|
|
90
|
-
## [1.2.0](https://github.com/portabletext/editor/compare/racejar-v1.1.3...racejar-v1.2.0) (2025-02-10)
|
|
91
|
-
|
|
92
|
-
### Features
|
|
93
|
-
|
|
94
|
-
- add support for `Before` and `After` hooks ([#784](https://github.com/portabletext/editor/issues/784)) ([0cee059](https://github.com/portabletext/editor/commit/0cee059aff7bb799ed51b608d8068490bc379d12))
|
|
95
|
-
- Add support for Data Tables and Doc Strings ([#783](https://github.com/portabletext/editor/issues/783)) ([2083aab](https://github.com/portabletext/editor/commit/2083aab7637ef5c5f95e25b5b4373b63869dde74))
|
|
96
|
-
|
|
97
|
-
## [1.1.3](https://github.com/portabletext/editor/compare/racejar-v1.1.2...racejar-v1.1.3) (2025-02-05)
|
|
98
|
-
|
|
99
|
-
### Bug Fixes
|
|
100
|
-
|
|
101
|
-
- **deps:** update dependency @playwright/test to ^1.50.1 ([5801c0e](https://github.com/portabletext/editor/commit/5801c0ed2cbfc85185b75cecd07cdb89a47a498b))
|
|
102
|
-
|
|
103
|
-
## [1.1.2](https://github.com/portabletext/editor/compare/racejar-v1.1.1...racejar-v1.1.2) (2025-01-27)
|
|
104
|
-
|
|
105
|
-
### Bug Fixes
|
|
106
|
-
|
|
107
|
-
- **deps:** update dependency @playwright/test to ^1.50.0 ([a55a0f5](https://github.com/portabletext/editor/commit/a55a0f591e59c77280c033c48d85bed8ea151bed))
|
|
108
|
-
|
|
109
|
-
## [1.1.1](https://github.com/portabletext/editor/compare/racejar-v1.1.0...racejar-v1.1.1) (2024-12-13)
|
|
110
|
-
|
|
111
|
-
### Bug Fixes
|
|
112
|
-
|
|
113
|
-
- **deps:** update dependency @playwright/test to ^1.49.1 ([21e0e3e](https://github.com/portabletext/editor/commit/21e0e3efe4b9451956f9d4133d65dca5147b3c64))
|
|
114
|
-
|
|
115
|
-
## [1.1.0](https://github.com/portabletext/editor/compare/racejar-v1.0.3...racejar-v1.1.0) (2024-12-02)
|
|
116
|
-
|
|
117
|
-
### Features
|
|
118
|
-
|
|
119
|
-
- **`compileFeature`:** allow passing context to each `step` ([05d6a23](https://github.com/portabletext/editor/commit/05d6a233d18eada7a46ff52520155f22d58f6ae4))
|
|
120
|
-
- add initial version of `racejar/playwright` ([2cac384](https://github.com/portabletext/editor/commit/2cac3846db0f01a157c00d55b0b7ba802278fe0a))
|
|
121
|
-
|
|
122
|
-
## [1.0.3](https://github.com/portabletext/editor/compare/racejar-v1.0.2...racejar-v1.0.3) (2024-12-01)
|
|
123
|
-
|
|
124
|
-
### Bug Fixes
|
|
125
|
-
|
|
126
|
-
- fix type error when defining inline steps without using generics ([d371044](https://github.com/portabletext/editor/commit/d371044dae46e87188bfc52cbadd8708748bb0ce))
|
|
127
|
-
|
|
128
|
-
## [1.0.2](https://github.com/portabletext/editor/compare/racejar-v1.0.1...racejar-v1.0.2) (2024-11-29)
|
|
129
|
-
|
|
130
|
-
### Bug Fixes
|
|
131
|
-
|
|
132
|
-
- allow synchronous step callbacks ([a8b1848](https://github.com/portabletext/editor/commit/a8b18489a5beaa1bd013d4753361357d53f44650))
|
|
133
|
-
- make parameter types optional ([3f35c97](https://github.com/portabletext/editor/commit/3f35c97cc2fcb7790f2edcd733132cefc35ae17d))
|
|
134
|
-
|
|
135
|
-
## [1.0.1](https://github.com/portabletext/editor/compare/racejar-v1.0.0...racejar-v1.0.1) (2024-11-26)
|
|
136
|
-
|
|
137
|
-
### Bug Fixes
|
|
138
|
-
|
|
139
|
-
- **deps:** update dependency vitest to ^2.1.5 ([bbceed5](https://github.com/portabletext/editor/commit/bbceed5c72ba6a9a9860fbbf89a939ae066d93f5))
|
|
140
|
-
- export ParameterType ([259c1a7](https://github.com/portabletext/editor/commit/259c1a7cce60a9c2106d6ee4c5d7c4d5da6c1917))
|
|
141
|
-
|
|
142
|
-
## 1.0.0 (2024-11-26)
|
|
143
|
-
|
|
144
|
-
### ⚠ BREAKING CHANGES
|
|
145
|
-
|
|
146
|
-
- release `racejar`
|
|
147
|
-
|
|
148
|
-
### Features
|
|
149
|
-
|
|
150
|
-
- release `racejar` ([b8f3f78](https://github.com/portabletext/editor/commit/b8f3f7885482282ba100d9c0c7eda84cbd72fce8))
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {expect} from 'vitest'
|
|
2
|
-
import {Given, Then, When} from '../src/step-definitions'
|
|
3
|
-
import {Feature} from '../src/vitest'
|
|
4
|
-
|
|
5
|
-
function greet(name: string, greeting: string) {
|
|
6
|
-
return `Hello ${name}, ${greeting}`
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
type Context = {
|
|
10
|
-
greetingPrefix: string
|
|
11
|
-
person: string
|
|
12
|
-
greeting: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Feature({
|
|
16
|
-
featureText: `
|
|
17
|
-
Feature: Greeting
|
|
18
|
-
Scenario: Greeting a person
|
|
19
|
-
Given the person "Herman"
|
|
20
|
-
When greeting the person with:
|
|
21
|
-
| how are you? |
|
|
22
|
-
Then the greeting is "Hello Herman, how are you?"`,
|
|
23
|
-
stepDefinitions: [
|
|
24
|
-
Given('the person {string}', (context: Context, person: string) => {
|
|
25
|
-
context.person = person
|
|
26
|
-
}),
|
|
27
|
-
When(
|
|
28
|
-
'greeting the person with:',
|
|
29
|
-
(context: Context, greeting: string[][]) => {
|
|
30
|
-
context.greeting = greet(context.person, greeting.at(0)?.at(0) ?? '')
|
|
31
|
-
},
|
|
32
|
-
),
|
|
33
|
-
Then('the greeting is {string}', (context: Context, greeting: string) => {
|
|
34
|
-
expect(context.greeting).toBe(greeting)
|
|
35
|
-
}),
|
|
36
|
-
],
|
|
37
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {expect} from 'vitest'
|
|
2
|
-
import {After, Before} from '../src/hooks'
|
|
3
|
-
import {Given, Then, When} from '../src/step-definitions'
|
|
4
|
-
import {Feature} from '../src/vitest'
|
|
5
|
-
|
|
6
|
-
function greet(prefix: string, name: string) {
|
|
7
|
-
return `${prefix} ${name}`
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type Context = {
|
|
11
|
-
greetingPrefix: string
|
|
12
|
-
person: string
|
|
13
|
-
greeting: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
Feature({
|
|
17
|
-
featureText: `
|
|
18
|
-
Feature: Greeting
|
|
19
|
-
Scenario: Greeting a person
|
|
20
|
-
Given the person "Herman"
|
|
21
|
-
When greeting the person
|
|
22
|
-
Then the greeting is "Hello Herman"
|
|
23
|
-
|
|
24
|
-
Scenario: Greeting another person
|
|
25
|
-
Given the person "Pauline"
|
|
26
|
-
When greeting the person
|
|
27
|
-
Then the greeting is "Hello Pauline"`,
|
|
28
|
-
hooks: [
|
|
29
|
-
Before((context: Context) => {
|
|
30
|
-
context.greetingPrefix = 'Hello'
|
|
31
|
-
}),
|
|
32
|
-
After((context: Context) => {
|
|
33
|
-
expect(context.greeting).toBe(
|
|
34
|
-
`${context.greetingPrefix} ${context.person}`,
|
|
35
|
-
)
|
|
36
|
-
}),
|
|
37
|
-
],
|
|
38
|
-
stepDefinitions: [
|
|
39
|
-
Given('the person {string}', (context: Context, person: string) => {
|
|
40
|
-
context.person = person
|
|
41
|
-
}),
|
|
42
|
-
When('greeting the person', (context: Context) => {
|
|
43
|
-
context.greeting = greet(context.greetingPrefix, context.person)
|
|
44
|
-
}),
|
|
45
|
-
Then('the greeting is {string}', (context: Context, greeting: string) => {
|
|
46
|
-
expect(context.greeting).toBe(greeting)
|
|
47
|
-
}),
|
|
48
|
-
],
|
|
49
|
-
})
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {expect} from '@playwright/test'
|
|
2
|
-
import {Feature, type PlaywrightContext} from '../src/playwright'
|
|
3
|
-
import {Given, Then, When} from '../src/step-definitions'
|
|
4
|
-
|
|
5
|
-
type Context = PlaywrightContext
|
|
6
|
-
|
|
7
|
-
Feature({
|
|
8
|
-
featureText: `
|
|
9
|
-
Feature: Playwright Homepage
|
|
10
|
-
Scenario: Navigating to Get Started
|
|
11
|
-
Given the homepage
|
|
12
|
-
When clicking the "Get started" link
|
|
13
|
-
Then the heading is "Installation"`,
|
|
14
|
-
stepDefinitions: [
|
|
15
|
-
Given('the homepage', async (context: Context) => {
|
|
16
|
-
await context.playwright.page.goto('https://playwright.dev/')
|
|
17
|
-
}),
|
|
18
|
-
When(
|
|
19
|
-
'clicking the {string} link',
|
|
20
|
-
async (context: Context, linkName: string) => {
|
|
21
|
-
await context.playwright.page
|
|
22
|
-
.getByRole('link', {name: linkName})
|
|
23
|
-
.click()
|
|
24
|
-
},
|
|
25
|
-
),
|
|
26
|
-
Then(
|
|
27
|
-
'the heading is {string}',
|
|
28
|
-
async (context: Context, heading: string) => {
|
|
29
|
-
await expect(
|
|
30
|
-
context.playwright.page.getByRole('heading', {name: heading}),
|
|
31
|
-
).toBeVisible()
|
|
32
|
-
},
|
|
33
|
-
),
|
|
34
|
-
],
|
|
35
|
-
})
|