@qavajs/playwright-runner-adapter 0.3.0 → 0.5.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/CHANGELOG.md +9 -0
- package/README.md +13 -8
- package/adapter/PlaywrightWorld.js +4 -0
- package/adapter/PlaywrightWorld.js.map +1 -1
- package/adapter/adapter.spec.js.map +1 -1
- package/adapter/defineCucumber.js +17 -3
- package/adapter/defineCucumber.js.map +1 -1
- package/adapter/loader.js +9 -6
- package/adapter/loader.js.map +1 -1
- package/package.json +7 -7
- package/src/PlaywrightWorld.ts +6 -2
- package/src/adapter.spec.ts +1 -0
- package/src/defineCucumber.ts +20 -3
- package/src/loader.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,15 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
|
|
10
10
|
:pencil: - chore
|
|
11
11
|
:microscope: - experimental
|
|
12
12
|
|
|
13
|
+
## [0.5.0]
|
|
14
|
+
- :rocket: updated gherkin dependency
|
|
15
|
+
- :rocket: added _expect_ to default world
|
|
16
|
+
|
|
17
|
+
## [0.4.0]
|
|
18
|
+
- :rocket: added support of _requireModules_ option
|
|
19
|
+
- :rocket: improved _defineCucumber_ function to encapsulate adapter path
|
|
20
|
+
- :beetle: updated typing for _init_ property of PlaywrightWorld
|
|
21
|
+
|
|
13
22
|
## [0.3.0]
|
|
14
23
|
- :rocket: added _defineCucumber_ util function
|
|
15
24
|
- :rocket: added logic to process duplicates
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[](https://badge.fury.io/js/@qavajs%2Fplaywright-runner-adapter)
|
|
2
2
|
|
|
3
3
|
# @qavajs/playwright-runner-adapter
|
|
4
|
-
Adapter to run
|
|
4
|
+
Adapter to run cucumber tests via playwright test runner
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
@@ -22,13 +22,11 @@ Set testDir to adapter
|
|
|
22
22
|
```typescript
|
|
23
23
|
import { defineCucumber } from '@qavajs/playwright-runner-adapter';
|
|
24
24
|
|
|
25
|
-
defineCucumber({
|
|
26
|
-
config: 'test/cucumber.ts',
|
|
27
|
-
profile: 'default'
|
|
28
|
-
});
|
|
29
|
-
|
|
30
25
|
export default defineConfig({
|
|
31
|
-
testDir:
|
|
26
|
+
testDir: defineCucumber({
|
|
27
|
+
config: 'test/cucumber.ts',
|
|
28
|
+
profile: 'default'
|
|
29
|
+
})
|
|
32
30
|
});
|
|
33
31
|
```
|
|
34
32
|
|
|
@@ -37,7 +35,7 @@ export default defineConfig({
|
|
|
37
35
|
Custom test instance can be passed to world constructor as _test_ property.
|
|
38
36
|
And then fixtures can be connected with world instance via _init_ property.
|
|
39
37
|
```typescript
|
|
40
|
-
import { test as base } from '@playwright/test';
|
|
38
|
+
import { test as base, expect as baseExpect } from '@playwright/test';
|
|
41
39
|
import { SettingsPage } from './settings-page';
|
|
42
40
|
import { setWorldConstructor } from '@cucumber/cucumber';
|
|
43
41
|
import { PlaywrightWorld } from '@qavajs/playwright-runner-adapter/PlaywrightWorld';
|
|
@@ -52,6 +50,12 @@ const customTest = base.extend<MyFixtures>({
|
|
|
52
50
|
},
|
|
53
51
|
});
|
|
54
52
|
|
|
53
|
+
const customExpect = baseExpect.extend({
|
|
54
|
+
async customMatcher() {
|
|
55
|
+
// implementation
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
55
59
|
class ExtendedPlaywrightWorld extends PlaywrightWorld {
|
|
56
60
|
settingsPage: SettingsPage;
|
|
57
61
|
constructor(options: any) {
|
|
@@ -60,6 +64,7 @@ class ExtendedPlaywrightWorld extends PlaywrightWorld {
|
|
|
60
64
|
|
|
61
65
|
// set test property with extened one
|
|
62
66
|
test = customTest;
|
|
67
|
+
expect = customExpect;
|
|
63
68
|
|
|
64
69
|
// init arrow function connects fixtures with Cucumber world instance
|
|
65
70
|
init = ({ settingsPage }) => {
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PlaywrightWorld = void 0;
|
|
4
4
|
const test_1 = require("@playwright/test");
|
|
5
|
+
/**
|
|
6
|
+
* Cucumber world for playwright adapter
|
|
7
|
+
*/
|
|
5
8
|
class PlaywrightWorld {
|
|
6
9
|
constructor(options) {
|
|
7
10
|
this.test = test_1.test;
|
|
11
|
+
this.expect = test_1.expect;
|
|
8
12
|
this.init = ({ browser, context, page }) => {
|
|
9
13
|
this.browser = browser;
|
|
10
14
|
this.context = context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightWorld.js","sourceRoot":"","sources":["../src/PlaywrightWorld.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"PlaywrightWorld.js","sourceRoot":"","sources":["../src/PlaywrightWorld.ts"],"names":[],"mappings":";;;AAAA,2CAAkG;AAElG;;GAEG;AACH,MAAa,eAAe;IAYxB,YAAY,OAAY;QAHxB,SAAI,GAAG,WAAI,CAAC;QACZ,WAAM,GAAG,aAAM,CAAC;QAQhB,SAAI,GAAiC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAA6D,EAAE,EAAE;YAC3H,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACrB,CAAC,CAAA;QATG,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACzC,CAAC;CAOJ;AAvBD,0CAuBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.spec.js","sourceRoot":"","sources":["../src/adapter.spec.ts"],"names":[],"mappings":";;AAAA,qCAAgC;AAEhC,MA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KAAK,MAAM,SAAS,IAAI,kBAAkB,CAAC,4BAA4B,EAAE,CAAC;oBACtE,IAAI,SAAS,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;wBACxC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;4BAChC,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;wBAClD,CAAC,CAAC,CAAC;oBACP,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAA;QACN,CAAC;QACD,KAAK,MAAM,YAAY,IAAI,kBAAkB,CAAC,2BAA2B,EAAE,CAAC;YACxE,IAAI,CAAC,QAAQ,CAAC,KAAK;gBACf,MAAM,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineCucumber =
|
|
3
|
+
exports.defineCucumber = defineCucumber;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
/**
|
|
6
|
+
* Define cucumber config in playwright config
|
|
7
|
+
* @param {CucumberConfig} config
|
|
8
|
+
* @example
|
|
9
|
+
* export default defineConfig({
|
|
10
|
+
* testDir: defineCucumber({
|
|
11
|
+
* config: 'cucumber.ts',
|
|
12
|
+
* profile: 'chrome', // optional
|
|
13
|
+
* adapter: 'path/to/adapter' // optional
|
|
14
|
+
* }),
|
|
15
|
+
* })
|
|
16
|
+
*/
|
|
4
17
|
function defineCucumber(config) {
|
|
18
|
+
var _a, _b;
|
|
5
19
|
process.env.CONFIG = config.config;
|
|
6
|
-
process.env.PROFILE = config.profile;
|
|
20
|
+
process.env.PROFILE = (_a = config.profile) !== null && _a !== void 0 ? _a : 'default';
|
|
21
|
+
return (_b = config.adapter) !== null && _b !== void 0 ? _b : (0, node_path_1.resolve)('./node_modules/@qavajs/playwright-runner-adapter/adapter');
|
|
7
22
|
}
|
|
8
|
-
exports.defineCucumber = defineCucumber;
|
|
9
23
|
//# sourceMappingURL=defineCucumber.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineCucumber.js","sourceRoot":"","sources":["../src/defineCucumber.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defineCucumber.js","sourceRoot":"","sources":["../src/defineCucumber.ts"],"names":[],"mappings":";;AAoBA,wCAIC;AAxBD,yCAAoC;AAQpC;;;;;;;;;;;GAWG;AACH,SAAgB,cAAc,CAAC,MAAsB;;IACjD,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,SAAS,CAAC;IAClD,OAAO,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAA,mBAAO,EAAC,0DAA0D,CAAC,CAAC;AACjG,CAAC"}
|
package/adapter/loader.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.loadFeatures = loadFeatures;
|
|
4
|
+
exports.loadStepDefinitions = loadStepDefinitions;
|
|
5
|
+
exports.load = load;
|
|
4
6
|
const node_fs_1 = require("node:fs");
|
|
5
7
|
const node_path_1 = require("node:path");
|
|
6
8
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -38,7 +40,6 @@ function loadFeatures(globPattern) {
|
|
|
38
40
|
};
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
|
-
exports.loadFeatures = loadFeatures;
|
|
42
43
|
function loadStepDefinitions(globPattern) {
|
|
43
44
|
cucumber_1.supportCodeLibraryBuilder.reset(process.cwd(), uuidFn);
|
|
44
45
|
cucumber_1.supportCodeLibraryBuilder.methods.setWorldConstructor(PlaywrightWorld_1.PlaywrightWorld);
|
|
@@ -49,15 +50,17 @@ function loadStepDefinitions(globPattern) {
|
|
|
49
50
|
}
|
|
50
51
|
return cucumber_1.supportCodeLibraryBuilder.finalize();
|
|
51
52
|
}
|
|
52
|
-
exports.loadStepDefinitions = loadStepDefinitions;
|
|
53
53
|
function load() {
|
|
54
|
-
var _a, _b;
|
|
54
|
+
var _a, _b, _c, _d, _e;
|
|
55
55
|
const config = require((0, node_path_1.join)(process.cwd(), (_a = process.env.CONFIG) !== null && _a !== void 0 ? _a : 'config.js'));
|
|
56
56
|
const profile = (_b = process.env.PROFILE) !== null && _b !== void 0 ? _b : 'default';
|
|
57
57
|
const resolvedConfig = config[profile];
|
|
58
58
|
const features = loadFeatures(resolvedConfig.paths);
|
|
59
|
-
const supportCodeLibrary = loadStepDefinitions(
|
|
59
|
+
const supportCodeLibrary = loadStepDefinitions([
|
|
60
|
+
...((_c = resolvedConfig.requireModules) !== null && _c !== void 0 ? _c : []),
|
|
61
|
+
...((_d = resolvedConfig.require) !== null && _d !== void 0 ? _d : []),
|
|
62
|
+
...((_e = resolvedConfig.import) !== null && _e !== void 0 ? _e : [])
|
|
63
|
+
]);
|
|
60
64
|
return { features, supportCodeLibrary };
|
|
61
65
|
}
|
|
62
|
-
exports.load = load;
|
|
63
66
|
//# sourceMappingURL=loader.js.map
|
package/adapter/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;AA4BA,oCAUC;AAED,kDASC;AAED,oBAYC;AA/DD,qCAAuC;AACvC,yCAA0C;AAC1C,6CAAyC;AACzC,+CAA4F;AAC5F,iDAA+D;AAC/D,+BAAgC;AAChC,uDAAoD;AAEpD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,EAAE,CAAA;AAC3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qavajs/playwright-runner-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "adapter for playwright test runner",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
"author": "Alexandr Galichenko",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@cucumber/gherkin": "^
|
|
14
|
-
"glob": "^
|
|
13
|
+
"@cucumber/gherkin": "^29.0.0",
|
|
14
|
+
"glob": "^11.0.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@cucumber/cucumber": "^
|
|
18
|
-
"@playwright/test": "^1.
|
|
19
|
-
"@types/node": "^
|
|
20
|
-
"typescript": "^5.4
|
|
17
|
+
"@cucumber/cucumber": "^11.0.0",
|
|
18
|
+
"@playwright/test": "^1.46.1",
|
|
19
|
+
"@types/node": "^22.5.4",
|
|
20
|
+
"typescript": "^5.5.4"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/src/PlaywrightWorld.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { APIRequestContext, Browser, BrowserContext, Page, test } from '@playwright/test';
|
|
1
|
+
import { APIRequestContext, Browser, BrowserContext, Page, test, expect } from '@playwright/test';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Cucumber world for playwright adapter
|
|
5
|
+
*/
|
|
3
6
|
export class PlaywrightWorld {
|
|
4
7
|
page!: Page;
|
|
5
8
|
context!: BrowserContext;
|
|
@@ -10,6 +13,7 @@ export class PlaywrightWorld {
|
|
|
10
13
|
attach!: (data: any, details?: { fileName?: string, mediaType: string }) => void;
|
|
11
14
|
parameters!: string;
|
|
12
15
|
test = test;
|
|
16
|
+
expect = expect;
|
|
13
17
|
|
|
14
18
|
constructor(options: any) {
|
|
15
19
|
this.log = options.log;
|
|
@@ -17,7 +21,7 @@ export class PlaywrightWorld {
|
|
|
17
21
|
this.parameters = options.parameters;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
init = ({ browser, context, page }: { browser: Browser, context: BrowserContext, page: Page }) => {
|
|
24
|
+
init: ({ [fixture: string]: any }) = ({ browser, context, page }: { browser: Browser, context: BrowserContext, page: Page }) => {
|
|
21
25
|
this.browser = browser;
|
|
22
26
|
this.context = context;
|
|
23
27
|
this.page = page;
|
package/src/adapter.spec.ts
CHANGED
|
@@ -5,6 +5,7 @@ const { features, supportCodeLibrary } = load();
|
|
|
5
5
|
function log(data: any) {
|
|
6
6
|
console.log(data);
|
|
7
7
|
}
|
|
8
|
+
|
|
8
9
|
function attach(this: { test: any }, body: any, details: any) {
|
|
9
10
|
const fileName = details.fileName ?? 'attachment';
|
|
10
11
|
const contentType = details.mediaType ?? 'text/plain';
|
package/src/defineCucumber.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
|
|
1
3
|
type CucumberConfig = {
|
|
2
4
|
config: string,
|
|
3
|
-
profile?: string
|
|
5
|
+
profile?: string,
|
|
6
|
+
adapter?: string
|
|
4
7
|
}
|
|
5
|
-
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Define cucumber config in playwright config
|
|
11
|
+
* @param {CucumberConfig} config
|
|
12
|
+
* @example
|
|
13
|
+
* export default defineConfig({
|
|
14
|
+
* testDir: defineCucumber({
|
|
15
|
+
* config: 'cucumber.ts',
|
|
16
|
+
* profile: 'chrome', // optional
|
|
17
|
+
* adapter: 'path/to/adapter' // optional
|
|
18
|
+
* }),
|
|
19
|
+
* })
|
|
20
|
+
*/
|
|
21
|
+
export function defineCucumber(config: CucumberConfig): string {
|
|
6
22
|
process.env.CONFIG = config.config;
|
|
7
|
-
process.env.PROFILE = config.profile;
|
|
23
|
+
process.env.PROFILE = config.profile ?? 'default';
|
|
24
|
+
return config.adapter ?? resolve('./node_modules/@qavajs/playwright-runner-adapter/adapter');
|
|
8
25
|
}
|
package/src/loader.ts
CHANGED
|
@@ -55,6 +55,10 @@ export function load() {
|
|
|
55
55
|
|
|
56
56
|
const resolvedConfig = config[profile];
|
|
57
57
|
const features = loadFeatures(resolvedConfig.paths);
|
|
58
|
-
const supportCodeLibrary = loadStepDefinitions(
|
|
58
|
+
const supportCodeLibrary = loadStepDefinitions([
|
|
59
|
+
...(resolvedConfig.requireModules ?? []),
|
|
60
|
+
...(resolvedConfig.require ?? []),
|
|
61
|
+
...(resolvedConfig.import ?? [])
|
|
62
|
+
]);
|
|
59
63
|
return { features, supportCodeLibrary }
|
|
60
64
|
}
|