@jscutlery/playwright-ct-angular 0.1.1 → 0.1.3

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/index.cjs CHANGED
@@ -62,45 +62,49 @@ playwright__namespace['_addRunnerPlugin'](() => {
62
62
  });
63
63
  const mountTest = playwright__namespace.test.extend(mount.fixtures);
64
64
  const test = mountTest.extend({
65
- /**
66
- * Override mount to return output spies and enjoy type inference.
67
- * This allows this:
68
- *
69
- * const { spies } = mount(..., {outputs: {citySelect: jest.fn()}})
70
- *
71
- * instead of this:
72
- *
73
- * const citySelectSpy: jest.MockedFunction<(city: string) => void> = jest.fn();
74
- * mount(..., {outputs: {citySelect: citySelectSpy}});
75
- *
76
- * @hack we are willingly not using `async mount(...)` syntax here
77
- * because it would be transpiled to `_async(function mount() { ... }`
78
- * by Nx's default rollout config.
79
- * Playwright dynamically parses the given function so converting
80
- * async / await to a wrapped function would simply break the library causing
81
- * a `TypeError: mount is not a function` error.
65
+ /**
66
+ * Override mount to return output spies and enjoy type inference.
67
+ * This allows this:
68
+ *
69
+ * const { spies } = mount(..., {outputs: {citySelect: jest.fn()}})
70
+ *
71
+ * instead of this:
72
+ *
73
+ * const citySelectSpy: jest.MockedFunction<(city: string) => void> = jest.fn();
74
+ * mount(..., {outputs: {citySelect: citySelectSpy}});
75
+ *
76
+ * @hack we are willingly not using `async mount(...)` syntax here
77
+ * because it would be transpiled to `_async(function mount() { ... }`
78
+ * by Nx's default rollout config.
79
+ * Playwright dynamically parses the given function so converting
80
+ * async / await to a wrapped function would simply break the library causing
81
+ * a `TypeError: mount is not a function` error.
82
82
  */
83
83
  mount({
84
84
  mount,
85
85
  page
86
86
  }, use) {
87
87
  return use(_async(function (component, options = {}) {
88
- var _options$spyOutputs$r, _options$spyOutputs;
89
88
  /* 1. Create a spy for each output in `spyOutputs`... */
90
- const spies = (_options$spyOutputs$r = (_options$spyOutputs = options.spyOutputs) == null ? void 0 : _options$spyOutputs.reduce((acc, key) => {
91
- return Object.assign({}, acc, {
89
+ const spies = options.spyOutputs?.reduce((acc, key) => {
90
+ return {
91
+ ...acc,
92
92
  [key]: jestMock.fn()
93
- });
94
- }, {})) != null ? _options$spyOutputs$r : {};
93
+ };
94
+ }, {}) ?? {};
95
95
  /* 2. ...then use it as an output... */
96
- return _await(mount(component, Object.assign({}, options, {
97
- outputs: Object.assign({}, options.outputs, spies)
98
- })), function () {
99
- /* Grab a locator to the TestBed's root element.
100
- * We are loading a fresh new page for each test
101
- * so the id should always be "root0".
102
- * Otherwise, we'd have to hack our way and somehow grab all
103
- * the `#root*`, sort them and grab the last one.
96
+ return _await(mount(component, {
97
+ ...options,
98
+ outputs: {
99
+ ...options.outputs,
100
+ ...spies
101
+ }
102
+ }), function () {
103
+ /* Grab a locator to the TestBed's root element.
104
+ * We are loading a fresh new page for each test
105
+ * so the id should always be "root0".
106
+ * Otherwise, we'd have to hack our way and somehow grab all
107
+ * the `#root*`, sort them and grab the last one.
104
108
  * As a matter of fact, we can't grab a reference to the fixture. */
105
109
  const locator = page.locator('#root0');
106
110
  /* Add spies to the returned locator. */
package/index.js CHANGED
@@ -15,45 +15,49 @@ playwright['_addRunnerPlugin'](() => {
15
15
  });
16
16
  const mountTest = playwright.test.extend(fixtures);
17
17
  const test = mountTest.extend({
18
- /**
19
- * Override mount to return output spies and enjoy type inference.
20
- * This allows this:
21
- *
22
- * const { spies } = mount(..., {outputs: {citySelect: jest.fn()}})
23
- *
24
- * instead of this:
25
- *
26
- * const citySelectSpy: jest.MockedFunction<(city: string) => void> = jest.fn();
27
- * mount(..., {outputs: {citySelect: citySelectSpy}});
28
- *
29
- * @hack we are willingly not using `async mount(...)` syntax here
30
- * because it would be transpiled to `_async(function mount() { ... }`
31
- * by Nx's default rollout config.
32
- * Playwright dynamically parses the given function so converting
33
- * async / await to a wrapped function would simply break the library causing
34
- * a `TypeError: mount is not a function` error.
18
+ /**
19
+ * Override mount to return output spies and enjoy type inference.
20
+ * This allows this:
21
+ *
22
+ * const { spies } = mount(..., {outputs: {citySelect: jest.fn()}})
23
+ *
24
+ * instead of this:
25
+ *
26
+ * const citySelectSpy: jest.MockedFunction<(city: string) => void> = jest.fn();
27
+ * mount(..., {outputs: {citySelect: citySelectSpy}});
28
+ *
29
+ * @hack we are willingly not using `async mount(...)` syntax here
30
+ * because it would be transpiled to `_async(function mount() { ... }`
31
+ * by Nx's default rollout config.
32
+ * Playwright dynamically parses the given function so converting
33
+ * async / await to a wrapped function would simply break the library causing
34
+ * a `TypeError: mount is not a function` error.
35
35
  */
36
36
  mount({
37
37
  mount,
38
38
  page
39
39
  }, use) {
40
40
  return use(async (component, options = {}) => {
41
- var _options$spyOutputs$r, _options$spyOutputs;
42
41
  /* 1. Create a spy for each output in `spyOutputs`... */
43
- const spies = (_options$spyOutputs$r = (_options$spyOutputs = options.spyOutputs) == null ? void 0 : _options$spyOutputs.reduce((acc, key) => {
44
- return Object.assign({}, acc, {
42
+ const spies = options.spyOutputs?.reduce((acc, key) => {
43
+ return {
44
+ ...acc,
45
45
  [key]: fn()
46
- });
47
- }, {})) != null ? _options$spyOutputs$r : {};
46
+ };
47
+ }, {}) ?? {};
48
48
  /* 2. ...then use it as an output... */
49
- await mount(component, Object.assign({}, options, {
50
- outputs: Object.assign({}, options.outputs, spies)
51
- }));
52
- /* Grab a locator to the TestBed's root element.
53
- * We are loading a fresh new page for each test
54
- * so the id should always be "root0".
55
- * Otherwise, we'd have to hack our way and somehow grab all
56
- * the `#root*`, sort them and grab the last one.
49
+ await mount(component, {
50
+ ...options,
51
+ outputs: {
52
+ ...options.outputs,
53
+ ...spies
54
+ }
55
+ });
56
+ /* Grab a locator to the TestBed's root element.
57
+ * We are loading a fresh new page for each test
58
+ * so the id should always be "root0".
59
+ * Otherwise, we'd have to hack our way and somehow grab all
60
+ * the `#root*`, sort them and grab the last one.
57
61
  * As a matter of fact, we can't grab a reference to the fixture. */
58
62
  const locator = page.locator('#root0');
59
63
  /* Add spies to the returned locator. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscutlery/playwright-ct-angular",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "dependencies": {
5
5
  "jest-mock": "^28.1.3",
6
6
  "rxjs": "^7.5.7",
@@ -11,15 +11,17 @@
11
11
  "@angular/platform-browser": "*",
12
12
  "@angular/platform-browser-dynamic": "*",
13
13
  "@playwright/test": "^1.28.0",
14
- "tslib": "*"
14
+ "tslib": "*",
15
+ "@angular/compiler": "16.0.1",
16
+ "zone.js": "0.13.0"
15
17
  },
16
18
  "module": "./index.js",
17
19
  "main": "./index.cjs",
18
20
  "type": "module",
19
- "types": "./index.d.ts",
21
+ "types": "./src/index.d.ts",
20
22
  "exports": {
21
23
  ".": {
22
- "types": "./index.d.ts",
24
+ "types": "./src/index.d.ts",
23
25
  "import": "./index.js",
24
26
  "require": "./index.cjs"
25
27
  }
@@ -1,2 +1,2 @@
1
- export { devices, expect, test } from './lib/playwright-ct-angular';
2
- export type { ComponentFixtures, PlaywrightTestConfig } from './lib/playwright-ct-angular';
1
+ export { devices, expect, test } from './lib/playwright-ct-angular';
2
+ export type { ComponentFixtures, PlaywrightTestConfig } from './lib/playwright-ct-angular';