@atomic-testing/playwright 0.18.0 → 0.19.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/PlaywrightInteractor.d.ts +8 -5
- package/dist/PlaywrightInteractor.js +34 -0
- package/dist/PlaywrightInteractor.js.map +1 -1
- package/dist/createTestEngine.js +0 -1
- package/dist/createTestEngine.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/testRunnerAdapter.d.ts +7 -0
- package/dist/{testAdapter.js → testRunnerAdapter.js} +10 -3
- package/dist/testRunnerAdapter.js.map +1 -0
- package/package.json +7 -7
- package/src/PlaywrightInteractor.ts +47 -7
- package/src/createTestEngine.ts +1 -2
- package/src/index.ts +1 -1
- package/src/{testAdapter.ts → testRunnerAdapter.ts} +13 -4
- package/dist/testAdapter.d.ts +0 -5
- package/dist/testAdapter.js.map +0 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClickOption, CssProperty, EnterTextOption, Interactor, LocatorChain, Optional } from '@atomic-testing/core';
|
|
2
2
|
import { Page } from '@playwright/test';
|
|
3
|
-
export declare class PlaywrightInteractor implements
|
|
3
|
+
export declare class PlaywrightInteractor implements Interactor {
|
|
4
4
|
readonly page: Page;
|
|
5
5
|
constructor(page: Page);
|
|
6
6
|
selectOptionValue(locator: LocatorChain, values: string[]): Promise<void>;
|
|
7
7
|
getInputValue(locator: LocatorChain): Promise<Optional<string>>;
|
|
8
8
|
getSelectValues(locator: LocatorChain): Promise<Optional<readonly string[]>>;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
getStyleValue(locator: LocatorChain, propertyName: CssProperty): Promise<Optional<string>>;
|
|
10
|
+
enterText(locator: LocatorChain, text: string, option?: Optional<Partial<EnterTextOption>>): Promise<void>;
|
|
11
|
+
click(locator: LocatorChain, option?: ClickOption): Promise<void>;
|
|
11
12
|
hover(locator: LocatorChain): Promise<void>;
|
|
13
|
+
wait(ms: number): Promise<void>;
|
|
12
14
|
getAttribute(locator: LocatorChain, name: string, isMultiple: true): Promise<readonly string[]>;
|
|
13
15
|
getAttribute(locator: LocatorChain, name: string, isMultiple: false): Promise<Optional<string>>;
|
|
14
16
|
getAttribute(locator: LocatorChain, name: string): Promise<Optional<string>>;
|
|
@@ -17,7 +19,8 @@ export declare class PlaywrightInteractor implements IInteractor {
|
|
|
17
19
|
isChecked(locator: LocatorChain): Promise<boolean>;
|
|
18
20
|
isDisabled(locator: LocatorChain): Promise<boolean>;
|
|
19
21
|
isReadonly(locator: LocatorChain): Promise<boolean>;
|
|
22
|
+
isVisible(locator: LocatorChain): Promise<boolean>;
|
|
20
23
|
hasCssClass(locator: LocatorChain, className: string): Promise<boolean>;
|
|
21
24
|
hasAttribute(locator: LocatorChain, name: string): Promise<boolean>;
|
|
22
|
-
clone():
|
|
25
|
+
clone(): Interactor;
|
|
23
26
|
}
|
|
@@ -46,6 +46,16 @@ class PlaywrightInteractor {
|
|
|
46
46
|
return values;
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
+
getStyleValue(locator, propertyName) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
52
|
+
const elLocator = this.page.locator(cssLocator);
|
|
53
|
+
const value = yield elLocator.evaluate((element, prop) => {
|
|
54
|
+
return window.getComputedStyle(element).getPropertyValue(prop);
|
|
55
|
+
}, propertyName);
|
|
56
|
+
return value;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
49
59
|
enterText(locator, text, option) {
|
|
50
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
61
|
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
@@ -67,6 +77,9 @@ class PlaywrightInteractor {
|
|
|
67
77
|
yield this.page.locator(cssLocator).hover();
|
|
68
78
|
});
|
|
69
79
|
}
|
|
80
|
+
wait(ms) {
|
|
81
|
+
return core_1.timingUtil.wait(ms);
|
|
82
|
+
}
|
|
70
83
|
getAttribute(locator, name, isMultiple) {
|
|
71
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
85
|
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
@@ -120,6 +133,27 @@ class PlaywrightInteractor {
|
|
|
120
133
|
return readonly != null;
|
|
121
134
|
});
|
|
122
135
|
}
|
|
136
|
+
isVisible(locator) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
const exists = yield this.exists(locator);
|
|
139
|
+
if (!exists) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
const opacity = yield this.getStyleValue(locator, 'opacity');
|
|
143
|
+
if (opacity === '0') {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const visibility = yield this.getStyleValue(locator, 'visibility');
|
|
147
|
+
if (visibility === 'hidden') {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
const display = yield this.getStyleValue(locator, 'display');
|
|
151
|
+
if (display === 'none') {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
return true;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
123
157
|
hasCssClass(locator, className) {
|
|
124
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
159
|
const classNames = yield this.getAttribute(locator, 'class');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightInteractor.js","sourceRoot":"","sources":["../src/PlaywrightInteractor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"PlaywrightInteractor.js","sourceRoot":"","sources":["../src/PlaywrightInteractor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAW8B;AAG9B,MAAa,oBAAoB;IAC/B,YAA4B,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAAG,CAAC;IAEpC,iBAAiB,CAAC,OAAqB,EAAE,MAA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,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAEK,WAAW,CAAC,OAAqB,EAAE,SAAiB;;YACxD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7D,IAAI,UAAU,IAAI,IAAI,EAAE;gBACtB,OAAO,KAAK,CAAC;aACd;YAED,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtC,OAAO,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;KAAA;IAEK,YAAY,CAAC,OAAqB,EAAE,IAAY;;YACpD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACzD,OAAO,SAAS,IAAI,IAAI,CAAC;QAC3B,CAAC;KAAA;IAED,KAAK;QACH,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF;AA9JD,oDA8JC"}
|
package/dist/createTestEngine.js
CHANGED
|
@@ -5,7 +5,6 @@ const core_1 = require("@atomic-testing/core");
|
|
|
5
5
|
const PlaywrightInteractor_1 = require("./PlaywrightInteractor");
|
|
6
6
|
function createTestEngine(page, partDefinitions) {
|
|
7
7
|
const engine = new core_1.TestEngine([], new PlaywrightInteractor_1.PlaywrightInteractor(page), {
|
|
8
|
-
perform: core_1.defaultStep,
|
|
9
8
|
parts: partDefinitions,
|
|
10
9
|
});
|
|
11
10
|
return engine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTestEngine.js","sourceRoot":"","sources":["../src/createTestEngine.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"createTestEngine.js","sourceRoot":"","sources":["../src/createTestEngine.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAG7D,iEAA8D;AAE9D,SAAgB,gBAAgB,CAAsB,IAAU,EAAE,eAAkB;IAClF,MAAM,MAAM,GAAG,IAAI,iBAAU,CAAC,EAAE,EAAE,IAAI,2CAAoB,CAAC,IAAI,CAAC,EAAE;QAChE,KAAK,EAAE,eAAe;KACvB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAND,4CAMC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,5 +19,5 @@ var createTestEngine_1 = require("./createTestEngine");
|
|
|
19
19
|
Object.defineProperty(exports, "createTestEngine", { enumerable: true, get: function () { return createTestEngine_1.createTestEngine; } });
|
|
20
20
|
var PlaywrightInteractor_1 = require("./PlaywrightInteractor");
|
|
21
21
|
Object.defineProperty(exports, "PlaywrightInteractor", { enumerable: true, get: function () { return PlaywrightInteractor_1.PlaywrightInteractor; } });
|
|
22
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./testRunnerAdapter"), exports);
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,sDAAoC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScenePart, TestEngine } from '@atomic-testing/core';
|
|
2
|
+
import { E2eTestInterface, E2eTestRunEnvironmentFixture, TestFrameworkMapper } from '@atomic-testing/test-runner';
|
|
3
|
+
export declare function goto(url: string): Promise<void>;
|
|
4
|
+
export declare function goto(url: string, fixture: E2eTestRunEnvironmentFixture): Promise<void>;
|
|
5
|
+
export declare function playwrightGetTestEngine<T extends ScenePart>(scenePart: T, fixture: E2eTestRunEnvironmentFixture): TestEngine<T>;
|
|
6
|
+
export declare const playWrightTestFrameworkMapper: TestFrameworkMapper;
|
|
7
|
+
export declare function getTestRunnerInterface<T extends ScenePart>(): E2eTestInterface<T>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.getTestRunnerInterface = exports.playWrightTestFrameworkMapper = exports.playwrightGetTestEngine = exports.goto = void 0;
|
|
13
13
|
const test_1 = require("@playwright/test");
|
|
14
14
|
const createTestEngine_1 = require("./createTestEngine");
|
|
15
15
|
function goto(url, fixture) {
|
|
@@ -24,7 +24,7 @@ function playwrightGetTestEngine(scenePart, fixture) {
|
|
|
24
24
|
return (0, createTestEngine_1.createTestEngine)(page, scenePart);
|
|
25
25
|
}
|
|
26
26
|
exports.playwrightGetTestEngine = playwrightGetTestEngine;
|
|
27
|
-
exports.
|
|
27
|
+
exports.playWrightTestFrameworkMapper = {
|
|
28
28
|
assertEqual: (a, b) => (0, test_1.expect)(a).toEqual(b),
|
|
29
29
|
// @ts-ignore
|
|
30
30
|
describe: test_1.test.describe,
|
|
@@ -39,4 +39,11 @@ exports.playWrightTestAdapter = {
|
|
|
39
39
|
// @ts-ignore
|
|
40
40
|
it: test_1.test,
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
function getTestRunnerInterface() {
|
|
43
|
+
return {
|
|
44
|
+
getTestEngine: playwrightGetTestEngine,
|
|
45
|
+
goto,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.getTestRunnerInterface = getTestRunnerInterface;
|
|
49
|
+
//# sourceMappingURL=testRunnerAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testRunnerAdapter.js","sourceRoot":"","sources":["../src/testRunnerAdapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,2CAAsD;AAEtD,yDAAsD;AAItD,SAAsB,IAAI,CAAC,GAAW,EAAE,OAAsC;;QAC5E,MAAM,IAAI,GAAG,OAAQ,CAAC,IAAY,CAAC;QACnC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;CAAA;AAHD,oBAGC;AAED,SAAgB,uBAAuB,CACrC,SAAY,EACZ,OAAqC;IAErC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAY,CAAC;IAClC,OAAO,IAAA,mCAAgB,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC;AAND,0DAMC;AAEY,QAAA,6BAA6B,GAAwB;IAChE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAA,aAAM,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,aAAa;IACb,QAAQ,EAAE,WAAI,CAAC,QAAQ;IAEvB,sDAAsD;IACtD,UAAU,EAAE,WAAI,CAAC,UAAU;IAC3B,SAAS,EAAE,WAAI,CAAC,SAAS;IACzB,SAAS,EAAE,WAAI,CAAC,SAAS;IACzB,QAAQ,EAAE,WAAI,CAAC,QAAQ;IACvB,qDAAqD;IAErD,aAAa;IACb,IAAI,EAAE,WAAI;IAEV,aAAa;IACb,EAAE,EAAE,WAAI;CACT,CAAC;AAEF,SAAgB,sBAAsB;IACpC,OAAO;QACL,aAAa,EAAE,uBAAuB;QACtC,IAAI;KACL,CAAC;AACJ,CAAC;AALD,wDAKC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomic-testing/playwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Atomic Testing Playwright Adapter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"url": "https://github.com/atomic-testing/atomic-testing.git"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@atomic-testing/core": "0.
|
|
19
|
-
"@atomic-testing/test-runner": "0.
|
|
18
|
+
"@atomic-testing/core": "0.19.0",
|
|
19
|
+
"@atomic-testing/test-runner": "0.19.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@playwright/test": "^1.
|
|
22
|
+
"@playwright/test": "^1.32.1",
|
|
23
23
|
"@types/node": "^16.0.0",
|
|
24
|
-
"jest": "^29.
|
|
25
|
-
"ts-jest": "^29.0.
|
|
24
|
+
"jest": "^29.5.0",
|
|
25
|
+
"ts-jest": "^29.0.5",
|
|
26
26
|
"ts-node": "^10.9.0",
|
|
27
|
-
"typescript": "^
|
|
27
|
+
"typescript": "^5.0.2"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@playwright/test": ">=1.30.2"
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
ClickOption,
|
|
3
|
+
CssProperty,
|
|
4
|
+
EnterTextOption,
|
|
5
|
+
Interactor,
|
|
5
6
|
LocatorChain,
|
|
6
7
|
LocatorType,
|
|
7
8
|
locatorUtil,
|
|
8
9
|
Optional,
|
|
9
10
|
PartLocatorType,
|
|
11
|
+
timingUtil,
|
|
10
12
|
} from '@atomic-testing/core';
|
|
11
13
|
import { Page } from '@playwright/test';
|
|
12
14
|
|
|
13
|
-
export class PlaywrightInteractor implements
|
|
15
|
+
export class PlaywrightInteractor implements Interactor {
|
|
14
16
|
constructor(public readonly page: Page) {}
|
|
17
|
+
|
|
15
18
|
async selectOptionValue(locator: LocatorChain, values: string[]): Promise<void> {
|
|
16
19
|
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
17
20
|
await this.page.locator(cssLocator).selectOption(values);
|
|
@@ -40,7 +43,16 @@ export class PlaywrightInteractor implements IInteractor {
|
|
|
40
43
|
return values;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
async
|
|
46
|
+
async getStyleValue(locator: LocatorChain, propertyName: CssProperty): Promise<Optional<string>> {
|
|
47
|
+
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
48
|
+
const elLocator = this.page.locator(cssLocator);
|
|
49
|
+
const value = await elLocator.evaluate((element, prop) => {
|
|
50
|
+
return window.getComputedStyle(element).getPropertyValue(prop as string);
|
|
51
|
+
}, propertyName);
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async enterText(locator: LocatorChain, text: string, option?: Optional<Partial<EnterTextOption>>): Promise<void> {
|
|
44
56
|
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
45
57
|
if (!option?.append) {
|
|
46
58
|
await this.page.locator(cssLocator).clear();
|
|
@@ -48,7 +60,7 @@ export class PlaywrightInteractor implements IInteractor {
|
|
|
48
60
|
await this.page.locator(cssLocator).type(text);
|
|
49
61
|
}
|
|
50
62
|
|
|
51
|
-
async click(locator: LocatorChain, option?:
|
|
63
|
+
async click(locator: LocatorChain, option?: ClickOption): Promise<void> {
|
|
52
64
|
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
53
65
|
await this.page.locator(cssLocator).click();
|
|
54
66
|
}
|
|
@@ -58,6 +70,10 @@ export class PlaywrightInteractor implements IInteractor {
|
|
|
58
70
|
await this.page.locator(cssLocator).hover();
|
|
59
71
|
}
|
|
60
72
|
|
|
73
|
+
wait(ms: number): Promise<void> {
|
|
74
|
+
return timingUtil.wait(ms);
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
async getAttribute(locator: LocatorChain, name: string, isMultiple: true): Promise<readonly string[]>;
|
|
62
78
|
async getAttribute(locator: LocatorChain, name: string, isMultiple: false): Promise<Optional<string>>;
|
|
63
79
|
async getAttribute(locator: LocatorChain, name: string): Promise<Optional<string>>;
|
|
@@ -112,6 +128,30 @@ export class PlaywrightInteractor implements IInteractor {
|
|
|
112
128
|
return readonly != null;
|
|
113
129
|
}
|
|
114
130
|
|
|
131
|
+
async isVisible(locator: LocatorChain): Promise<boolean> {
|
|
132
|
+
const exists = await this.exists(locator);
|
|
133
|
+
if (!exists) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const opacity = await this.getStyleValue(locator, 'opacity');
|
|
138
|
+
if (opacity === '0') {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const visibility = await this.getStyleValue(locator, 'visibility');
|
|
143
|
+
if (visibility === 'hidden') {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const display = await this.getStyleValue(locator, 'display');
|
|
148
|
+
if (display === 'none') {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
115
155
|
async hasCssClass(locator: LocatorChain, className: string): Promise<boolean> {
|
|
116
156
|
const classNames = await this.getAttribute(locator, 'class');
|
|
117
157
|
if (classNames == null) {
|
|
@@ -127,7 +167,7 @@ export class PlaywrightInteractor implements IInteractor {
|
|
|
127
167
|
return attrValue != null;
|
|
128
168
|
}
|
|
129
169
|
|
|
130
|
-
clone():
|
|
170
|
+
clone(): Interactor {
|
|
131
171
|
return new PlaywrightInteractor(this.page);
|
|
132
172
|
}
|
|
133
173
|
}
|
package/src/createTestEngine.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScenePart, TestEngine } from '@atomic-testing/core';
|
|
2
2
|
import { Page } from '@playwright/test';
|
|
3
3
|
|
|
4
4
|
import { PlaywrightInteractor } from './PlaywrightInteractor';
|
|
5
5
|
|
|
6
6
|
export function createTestEngine<T extends ScenePart>(page: Page, partDefinitions: T): TestEngine<T> {
|
|
7
7
|
const engine = new TestEngine([], new PlaywrightInteractor(page), {
|
|
8
|
-
perform: defaultStep,
|
|
9
8
|
parts: partDefinitions,
|
|
10
9
|
});
|
|
11
10
|
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ScenePart, TestEngine } from '@atomic-testing/core';
|
|
2
|
-
import { E2eTestRunEnvironmentFixture, TestFrameworkMapper } from '@atomic-testing/test-runner';
|
|
2
|
+
import { E2eTestInterface, E2eTestRunEnvironmentFixture, TestFrameworkMapper } from '@atomic-testing/test-runner';
|
|
3
3
|
import { expect, Page, test } from '@playwright/test';
|
|
4
4
|
|
|
5
5
|
import { createTestEngine } from './createTestEngine';
|
|
6
6
|
|
|
7
|
-
export async function goto(url: string
|
|
8
|
-
|
|
7
|
+
export async function goto(url: string): Promise<void>;
|
|
8
|
+
export async function goto(url: string, fixture: E2eTestRunEnvironmentFixture): Promise<void>;
|
|
9
|
+
export async function goto(url: string, fixture?: E2eTestRunEnvironmentFixture): Promise<void> {
|
|
10
|
+
const page = fixture!.page as Page;
|
|
9
11
|
await page.goto(url);
|
|
10
12
|
}
|
|
11
13
|
|
|
@@ -17,7 +19,7 @@ export function playwrightGetTestEngine<T extends ScenePart>(
|
|
|
17
19
|
return createTestEngine(page, scenePart);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
export const
|
|
22
|
+
export const playWrightTestFrameworkMapper: TestFrameworkMapper = {
|
|
21
23
|
assertEqual: (a, b) => expect(a).toEqual(b),
|
|
22
24
|
// @ts-ignore
|
|
23
25
|
describe: test.describe,
|
|
@@ -35,3 +37,10 @@ export const playWrightTestAdapter: TestFrameworkMapper = {
|
|
|
35
37
|
// @ts-ignore
|
|
36
38
|
it: test,
|
|
37
39
|
};
|
|
40
|
+
|
|
41
|
+
export function getTestRunnerInterface<T extends ScenePart>(): E2eTestInterface<T> {
|
|
42
|
+
return {
|
|
43
|
+
getTestEngine: playwrightGetTestEngine,
|
|
44
|
+
goto,
|
|
45
|
+
};
|
|
46
|
+
}
|
package/dist/testAdapter.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ScenePart, TestEngine } from '@atomic-testing/core';
|
|
2
|
-
import { E2eTestRunEnvironmentFixture, TestFrameworkMapper } from '@atomic-testing/test-runner';
|
|
3
|
-
export declare function goto(url: string, fixture: E2eTestRunEnvironmentFixture): Promise<void>;
|
|
4
|
-
export declare function playwrightGetTestEngine<T extends ScenePart>(scenePart: T, fixture: E2eTestRunEnvironmentFixture): TestEngine<T>;
|
|
5
|
-
export declare const playWrightTestAdapter: TestFrameworkMapper;
|
package/dist/testAdapter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testAdapter.js","sourceRoot":"","sources":["../src/testAdapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,2CAAsD;AAEtD,yDAAsD;AAEtD,SAAsB,IAAI,CAAC,GAAW,EAAE,OAAqC;;QAC3E,MAAM,IAAI,GAAG,OAAO,CAAC,IAAY,CAAC;QAClC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;CAAA;AAHD,oBAGC;AAED,SAAgB,uBAAuB,CACrC,SAAY,EACZ,OAAqC;IAErC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAY,CAAC;IAClC,OAAO,IAAA,mCAAgB,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC;AAND,0DAMC;AAEY,QAAA,qBAAqB,GAAwB;IACxD,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAA,aAAM,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,aAAa;IACb,QAAQ,EAAE,WAAI,CAAC,QAAQ;IAEvB,sDAAsD;IACtD,UAAU,EAAE,WAAI,CAAC,UAAU;IAC3B,SAAS,EAAE,WAAI,CAAC,SAAS;IACzB,SAAS,EAAE,WAAI,CAAC,SAAS;IACzB,QAAQ,EAAE,WAAI,CAAC,QAAQ;IACvB,qDAAqD;IAErD,aAAa;IACb,IAAI,EAAE,WAAI;IAEV,aAAa;IACb,EAAE,EAAE,WAAI;CACT,CAAC"}
|