@genesislcap/foundation-testing 10.3.1 → 11.3.1

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.
Files changed (91) hide show
  1. package/README.md +1 -1
  2. package/dist/dts/playwright/setup.d.ts.map +1 -1
  3. package/dist/dts/playwright/test.d.ts +32 -5
  4. package/dist/dts/playwright/test.d.ts.map +1 -1
  5. package/dist/dts/suite/suite.d.ts +8 -1
  6. package/dist/dts/suite/suite.d.ts.map +1 -1
  7. package/dist/dts/utils/harness.d.ts +75 -0
  8. package/dist/dts/utils/harness.d.ts.map +1 -0
  9. package/dist/dts/utils/index.d.ts +2 -0
  10. package/dist/dts/utils/index.d.ts.map +1 -1
  11. package/dist/dts/utils/types.d.ts +11 -0
  12. package/dist/dts/utils/types.d.ts.map +1 -0
  13. package/dist/esm/component/fixture.js +0 -1
  14. package/dist/esm/component/index.js +0 -1
  15. package/dist/esm/index.federated.js +0 -1
  16. package/dist/esm/index.js +0 -1
  17. package/dist/esm/jsdom/setup.js +0 -1
  18. package/dist/esm/playwright/index.js +0 -1
  19. package/dist/esm/playwright/setup.js +5 -1
  20. package/dist/esm/playwright/test.js +42 -13
  21. package/dist/esm/suite/index.js +0 -1
  22. package/dist/esm/suite/suite.js +1 -2
  23. package/dist/esm/utils/harness.js +55 -0
  24. package/dist/esm/utils/index.js +2 -1
  25. package/dist/esm/utils/logger.js +0 -1
  26. package/dist/esm/utils/types.js +2 -0
  27. package/dist/esm/uvu/index.js +0 -1
  28. package/dist/esm/uvu/uvu.js +0 -1
  29. package/dist/foundation-testing.api.json +506 -0
  30. package/dist/foundation-testing.d.ts +100 -0
  31. package/docs/api/foundation-testing.equal.md +13 -0
  32. package/docs/api/foundation-testing.expect.md +13 -0
  33. package/docs/api/foundation-testing.filterconditionally.md +15 -0
  34. package/docs/api/foundation-testing.md +9 -0
  35. package/docs/api/foundation-testing.resettestharness.md +24 -0
  36. package/docs/api/foundation-testing.sinonwrapper.md +17 -0
  37. package/docs/api/foundation-testing.spiedfunctions.md +15 -0
  38. package/docs/api/foundation-testing.suitecallback.md +15 -0
  39. package/docs/api/foundation-testing.testspy.md +38 -0
  40. package/docs/api/foundation-testing.withtestharness.md +17 -0
  41. package/docs/api-report.md +123 -87
  42. package/package.json +12 -7
  43. package/dist/1.0.0.remoteEntry.js +0 -1
  44. package/dist/191.0099ca6c24422254d51d36c222dc6023.js.map +0 -1
  45. package/dist/191.191.613504f8a55556ba573c.js +0 -2
  46. package/dist/259.1ff0e7689abdc0527a57f2eb20369ada.js.map +0 -1
  47. package/dist/259.259.724449a74ba114ef0d82.js +0 -2
  48. package/dist/415.32cf4cabeed75f5d759d12434a4de5c7.js.map +0 -1
  49. package/dist/415.415.ee8e35767118401bccab.js +0 -3
  50. package/dist/415.415.ee8e35767118401bccab.js.LICENSE.txt +0 -4
  51. package/dist/623.1b885cabcffad0807eeb0de7ad5dd497.js.map +0 -1
  52. package/dist/623.623.148af50848667bfda381.js +0 -3
  53. package/dist/623.623.148af50848667bfda381.js.LICENSE.txt +0 -4
  54. package/dist/755.497b49c90948bc3e157823cb2632c52a.js.map +0 -1
  55. package/dist/755.755.5f9603173373118bd373.js +0 -2
  56. package/dist/772.1d442e2541aac79f2c1091cc41a66926.js.map +0 -1
  57. package/dist/772.772.76d81e3af1ce835f1f47.js +0 -2
  58. package/dist/dashboard.json +0 -1
  59. package/dist/esm/component/fixture.js.map +0 -1
  60. package/dist/esm/component/index.js.map +0 -1
  61. package/dist/esm/index.federated.js.map +0 -1
  62. package/dist/esm/index.js.map +0 -1
  63. package/dist/esm/jsdom/setup.js.map +0 -1
  64. package/dist/esm/playwright/index.js.map +0 -1
  65. package/dist/esm/playwright/setup.js.map +0 -1
  66. package/dist/esm/playwright/test.js.map +0 -1
  67. package/dist/esm/suite/index.js.map +0 -1
  68. package/dist/esm/suite/suite.js.map +0 -1
  69. package/dist/esm/utils/index.js.map +0 -1
  70. package/dist/esm/utils/logger.js.map +0 -1
  71. package/dist/esm/uvu/index.js.map +0 -1
  72. package/dist/esm/uvu/uvu.js.map +0 -1
  73. package/dist/favicon.ico +0 -0
  74. package/dist/foundation-testing.iife.min.js +0 -15
  75. package/dist/foundation-testing.js +0 -6991
  76. package/dist/foundation-testing.min.js +0 -15
  77. package/dist/foundationTesting.f38614af33c4c4be86b1918f8d126cd9.js.map +0 -1
  78. package/dist/index.ejs +0 -23
  79. package/dist/index.html +0 -14
  80. package/dist/info.ejs +0 -13
  81. package/dist/main.484382eb648d01b1b33d.js +0 -2
  82. package/dist/main.f58a8d7f17348e63bf4abb67acf3e598.js.map +0 -1
  83. package/dist/npm.consola.713.2f64f3cac7864c3b4057.js +0 -2
  84. package/dist/npm.consola.8813a44257414a02ed3be5608793f087.js.map +0 -1
  85. package/dist/npm.diff.83d06b572c2ee1bd4957fc9f121bf65a.js.map +0 -1
  86. package/dist/npm.diff.852.9166591dbfda57fefcc7.js +0 -2
  87. package/dist/npm.microsoft.127.8c2d0309b2c5ee49f9ed.js +0 -1469
  88. package/dist/npm.microsoft.127.8c2d0309b2c5ee49f9ed.js.LICENSE.txt +0 -14
  89. package/dist/npm.microsoft.53571229b0cfc6a6b1b069cfe9a8483d.js.map +0 -1
  90. package/dist/remoteEntry.js +0 -2
  91. package/dist/serve.json +0 -3
package/README.md CHANGED
@@ -97,7 +97,7 @@ The test related scripts to add to your package's `package.json` file may includ
97
97
  "test:coverage:report": "npm run test:coverage && c8 report --reporter=text-lcov > coverage.lcov",
98
98
  "test:coverage:report:nyc": "npm run test:unit:browser -- --cov && npx nyc report --reporter=html",
99
99
  "test:e2e": "npx playwright test --config=./playwright.config.ts",
100
- "test:e2e:debug": "cross-env PWDEBUG=1 npm run test:e2e",
100
+ "test:e2e:debug": "npm run test:e2e -- --debug",
101
101
  "test:unit": "npm run test:unit:node",
102
102
  "test:unit:browser": "playwright-test \"./**/*.test.ts\" --runner uvu",
103
103
  "test:unit:browser:watch": "npm run test:unit:browser -- -w -d",
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/playwright/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;;;;;GAQG;AACH,iBAAe,KAAK,CAAC,MAAM,EAAE,UAAU,gCAOtC;AAED,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/playwright/setup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;;;;;;GAQG;AACH,iBAAe,KAAK,CAAC,MAAM,EAAE,UAAU,gCAStC;AAED,eAAe,KAAK,CAAC"}
@@ -1,16 +1,43 @@
1
+ import { Browser } from '@playwright/test';
1
2
  /**
2
- * Extend and add fixtures to share across e2e test suite.
3
3
  * @public
4
4
  */
5
- export type Fixtures = {
6
- hostPage(): Promise<void>;
5
+ export type PackageConfig = {
6
+ API_HOST?: string;
7
+ DEFAULT_USER?: string;
8
+ DEFAULT_PASSWORD?: string;
9
+ PORT?: number;
7
10
  };
8
11
  /**
9
- * Playwright test.
12
+ * @public
13
+ */
14
+ export type AuditThresholds = {
15
+ performance?: number;
16
+ accessibility?: number;
17
+ 'best-practices'?: number;
18
+ seo?: number;
19
+ pwa?: number;
20
+ };
21
+ export declare const defaultAuditThresholds: AuditThresholds;
22
+ /**
23
+ * @public
24
+ */
25
+ export type TestFixture = {};
26
+ /**
27
+ * @public
28
+ */
29
+ export type WorkerFixture = {
30
+ config: PackageConfig;
31
+ port: number;
32
+ browser: Browser;
33
+ audit: AuditThresholds;
34
+ };
35
+ /**
36
+ * Playwright test
10
37
  * @public
11
38
  * @remarks
12
39
  * This is just an example playwright test fixture stub. In reality, you will likely create a custom
13
40
  * fixture for your e2e tests depending on the needs of your app or micro frontend.
14
41
  */
15
- export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & Fixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
42
+ export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & WorkerFixture>;
16
43
  //# sourceMappingURL=test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../src/playwright/test.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,wPAWf,CAAC"}
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../src/playwright/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA0B,MAAM,kBAAkB,CAAC;AAGnE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AASF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,eAMpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,6PAmBf,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { FoundationElement, FoundationElementDefinition, FoundationElementRegistry, Registration } from '@microsoft/fast-foundation';
2
2
  import { Container, DesignSystem } from '@microsoft/fast-foundation';
3
- import { assert, uvu } from '../uvu';
4
3
  import { Fixture } from '../component';
4
+ import { assert, uvu } from '../uvu';
5
5
  /**
6
6
  * @public
7
7
  */
@@ -21,6 +21,13 @@ export interface ComponentContext<TElement = HTMLElement> extends Pick<Fixture<T
21
21
  export interface LogicContext {
22
22
  runCases?(fn: (value: any) => any, cases: [any, any, assert.Message?][]): void;
23
23
  }
24
+ /**
25
+ * Defines the Generic type for a test Suite `T` the callback function
26
+ * required to assert on type `T`.
27
+ * @typeParam T - the top level class we are testing
28
+ * @public
29
+ */
30
+ export type SuiteCallback<T> = uvu.Callback<ComponentContext<T>>;
24
31
  /**
25
32
  * Create component test suite.
26
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"suite.d.ts","sourceRoot":"","sources":["../../../src/suite/suite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,yBAAyB,EACzB,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAM,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAS,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,OAAO,EAA0C,MAAM,cAAc,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,yBAAyB,CACzD,2BAA2B,EAC3B,iBAAiB,CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,QAAQ,GAAG,WAAW,CACtD,SAAQ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AG,CAAC,IAAI,CAAC,QAAQ,CAAC,CASpB"}
@@ -0,0 +1,75 @@
1
+ import sinon from 'sinon';
2
+ /**
3
+ * Filters out key/value pairs from an object where they value does not match a condition
4
+ * @public
5
+ */
6
+ export type FilterConditionally<Source, Condition> = Pick<Source, {
7
+ [K in keyof Source]: Source[K] extends Condition ? K : never;
8
+ }[keyof Source]>;
9
+ /**
10
+ * Filters out all key/value pairs which are not functions, and omits the constructor
11
+ * @public
12
+ */
13
+ export type SpiedFunctions<T> = Omit<FilterConditionally<T, (...args: any[]) => any>, 'constructor'>;
14
+ /**
15
+ * Crates an object with a key value pair for each spied function
16
+ * where the key is the function name and the value is the sinon wrapped
17
+ * spy function
18
+ * @public
19
+ * @typeParam T - object with keys where values are functions
20
+ */
21
+ export type SinonWrapper<T extends {
22
+ [K in keyof T]: (...args: any) => any;
23
+ }> = {
24
+ [K in keyof T]: sinon.SinonSpy<Parameters<T[K]>, ReturnType<T[K]>>;
25
+ };
26
+ /**
27
+ * Type can be used to inform Typescript the object decorated with {@link testSpy} has function
28
+ * spies which can be interacted upon their normal function reference
29
+ * @public
30
+ */
31
+ export type WithTestHarness<T extends {
32
+ [k in keyof T]: any;
33
+ }> = T & SinonWrapper<SpiedFunctions<T>>;
34
+ /**
35
+ * Decorator: Used on a test harness class based on a `FoundationElement` to give it extra functionality
36
+ * which can be used during testing. *Important* this is to be used on a parent element compared to
37
+ * the element under test.
38
+ *
39
+ *
40
+ * @remarks
41
+ * Access the test functionality using the type with {@link WithTestHarness}
42
+ *
43
+ * Reset after each test with {@link resetTestHarness}
44
+ *
45
+ * @example
46
+ *
47
+ * // Testing the first function call
48
+ * async (\{ element \}) =\> \{
49
+ *
50
+ assert.ok(
51
+ element.layout.addItemFromChild.calledWith(\{
52
+ type: 'component',
53
+ componentType: 'test',
54
+ title: `Item test`,
55
+ reorderEnabled: true,
56
+ isClosable: false,
57
+ size: undefined,
58
+ \})
59
+ );
60
+ *
61
+ * // Reset the tester at the end of every test even if you don't assert on any of it!
62
+ * resetTestHarness(element.layout);
63
+ * \}
64
+ *
65
+ * @public
66
+ */
67
+ export declare function testSpy(constructor: Function): void;
68
+ /**
69
+ * Resets items tracked during testing such as calls to spied functions.
70
+ * Must be called at the end of every test even if not asserting on the spies.
71
+ * @param wrapper - `WithTestHarness<T>` object to reset
72
+ * @public
73
+ */
74
+ export declare function resetTestHarness<T>(wrapper: WithTestHarness<T>): void;
75
+ //# sourceMappingURL=harness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../../../src/utils/harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,MAAM,EAAE,SAAS,IAAI,IAAI,CACvD,MAAM,EACN;KAAG,CAAC,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,KAAK;CAAE,CAAC,MAAM,MAAM,CAAC,CAC/E,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,IAAI,CAClC,mBAAmB,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAC/C,aAAa,CACd,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG;CAAE,IAAI;KAC7E,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACnE,CAAC;AACF;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG;CAAE,IAAI,CAAC,GAChE,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAYlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,OAAO,CAAC,WAAW,EAAE,QAAQ,QAK5C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,QAE9D"}
@@ -1,2 +1,4 @@
1
1
  export * from './logger';
2
+ export * from './harness';
3
+ export * from './types';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Expects that the type parameter T resolves to true, or will be a typescript error
3
+ * @public
4
+ */
5
+ export type Expect<T extends true> = T;
6
+ /**
7
+ * Expects that the type parameter X is equal to Y, returning true or false
8
+ * @public
9
+ */
10
+ export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,GACzF,IAAI,GACJ,KAAK,CAAC"}
@@ -84,4 +84,3 @@ export function fixture(templateNameOrRegistry, options = {}) {
84
84
  };
85
85
  });
86
86
  }
87
- //# sourceMappingURL=fixture.js.map
@@ -1,2 +1 @@
1
1
  export * from './fixture';
2
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
1
  import('./index');
2
- //# sourceMappingURL=index.federated.js.map
package/dist/esm/index.js CHANGED
@@ -8,4 +8,3 @@ export * from './component';
8
8
  export * from './suite';
9
9
  export * from './utils';
10
10
  export * from './uvu';
11
- //# sourceMappingURL=index.js.map
@@ -89,4 +89,3 @@ export const teardown = () => __awaiter(void 0, void 0, void 0, function* () {
89
89
  * Run setup on import by default.
90
90
  */
91
91
  setup();
92
- //# sourceMappingURL=setup.js.map
@@ -2,4 +2,3 @@
2
2
  * Do not export setup
3
3
  */
4
4
  export * from './test';
5
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,7 @@
1
1
  import { __awaiter } from "tslib";
2
+ import os from 'os';
3
+ import path from 'path';
4
+ import rimraf from 'rimraf';
2
5
  /**
3
6
  * @param config - A playwright configuration object.
4
7
  * @returns A teardown function.
@@ -16,9 +19,10 @@ function setup(config) {
16
19
  return __awaiter(this, void 0, void 0, function* () {
17
20
  delete process.env.FOO;
18
21
  delete process.env.BAR;
22
+ const tmpDirPath = path.join(os.tmpdir(), 'pw');
23
+ rimraf(tmpDirPath, console.log);
19
24
  });
20
25
  };
21
26
  });
22
27
  }
23
28
  export default setup;
24
- //# sourceMappingURL=setup.js.map
@@ -1,22 +1,51 @@
1
1
  import { __awaiter } from "tslib";
2
- import { test as base } from '@playwright/test';
2
+ import { chromium, test as base } from '@playwright/test';
3
+ import { getPort } from 'portfinder-sync';
4
+ const defaultPackageConfig = {
5
+ API_HOST: 'wss://public-foundation.genesislab.global/gwf/',
6
+ DEFAULT_USER: 'JohnDoe',
7
+ DEFAULT_PASSWORD: 'Password11*',
8
+ PORT: 5030,
9
+ };
10
+ export const defaultAuditThresholds = {
11
+ performance: 45,
12
+ accessibility: 60,
13
+ 'best-practices': 60,
14
+ seo: 60,
15
+ pwa: 30,
16
+ };
3
17
  /**
4
- * Playwright test.
18
+ * Playwright test
5
19
  * @public
6
20
  * @remarks
7
21
  * This is just an example playwright test fixture stub. In reality, you will likely create a custom
8
22
  * fixture for your e2e tests depending on the needs of your app or micro frontend.
9
23
  */
10
24
  export const test = base.extend({
11
- hostPage: ({ page }, use) => __awaiter(void 0, void 0, void 0, function* () {
12
- /**
13
- * const host = new HostPage(page);
14
- * await host.goto();
15
- * await host.addSomeThing('something');
16
- * await use(host);
17
- * await host.destroy();
18
- */
19
- yield use(null);
20
- }),
25
+ config: [defaultPackageConfig, { option: true, scope: 'worker' }],
26
+ port: [
27
+ ({ config }, use) => __awaiter(void 0, void 0, void 0, function* () {
28
+ const port = getPort((config === null || config === void 0 ? void 0 : config.PORT) || process.env.PORT || defaultPackageConfig.PORT);
29
+ yield use(port);
30
+ }),
31
+ { scope: 'worker' }, // option: true
32
+ ],
33
+ browser: [
34
+ ({ port }, use) => __awaiter(void 0, void 0, void 0, function* () {
35
+ const browser = yield chromium.launch({
36
+ args: [`--remote-debugging-port=${port}`],
37
+ });
38
+ yield use(browser);
39
+ }),
40
+ { scope: 'worker' },
41
+ ],
42
+ audit: [defaultAuditThresholds, { option: true, scope: 'worker' }], // TODO: These are not being used from other test setups extending this.
21
43
  });
22
- //# sourceMappingURL=test.js.map
44
+ // Perhaps we keen extending the test up the package chain... spread the mf tests into our app test
45
+ // const test2 = test.extend<{ foo: boolean }>({
46
+ // foo: [true, { option: true }],
47
+ // });
48
+ //
49
+ // a('lighthouse audit', async ({ foo, page }) => {
50
+ //
51
+ // });
@@ -1,2 +1 @@
1
1
  export * from './suite';
2
- //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { DesignSystem, DI } from '@microsoft/fast-foundation';
3
- import { assert, suite } from '../uvu';
4
3
  import { fixture as FASTFixture } from '../component';
4
+ import { assert, suite } from '../uvu';
5
5
  /**
6
6
  * Create component test suite.
7
7
  *
@@ -141,4 +141,3 @@ export function createLogicSuite(title, context) {
141
141
  } }, context));
142
142
  return Suite;
143
143
  }
144
- //# sourceMappingURL=suite.js.map
@@ -0,0 +1,55 @@
1
+ import sinon from 'sinon';
2
+ /**
3
+ * Predicate function used to check whether the object's value is a function
4
+ * we want to spy on. We want to spy on all functions, except the constructor
5
+ * @internal
6
+ */
7
+ const shouldSpy = (proto) => (k) => typeof proto[k] === 'function' && k !== 'constructor';
8
+ /**
9
+ * Decorator: Used on a test harness class based on a `FoundationElement` to give it extra functionality
10
+ * which can be used during testing. *Important* this is to be used on a parent element compared to
11
+ * the element under test.
12
+ *
13
+ *
14
+ * @remarks
15
+ * Access the test functionality using the type with {@link WithTestHarness}
16
+ *
17
+ * Reset after each test with {@link resetTestHarness}
18
+ *
19
+ * @example
20
+ *
21
+ * // Testing the first function call
22
+ * async (\{ element \}) =\> \{
23
+ *
24
+ assert.ok(
25
+ element.layout.addItemFromChild.calledWith(\{
26
+ type: 'component',
27
+ componentType: 'test',
28
+ title: `Item test`,
29
+ reorderEnabled: true,
30
+ isClosable: false,
31
+ size: undefined,
32
+ \})
33
+ );
34
+ *
35
+ * // Reset the tester at the end of every test even if you don't assert on any of it!
36
+ * resetTestHarness(element.layout);
37
+ * \}
38
+ *
39
+ * @public
40
+ */
41
+ export function testSpy(constructor) {
42
+ constructor['_test'] = sinon.createSandbox();
43
+ Object.getOwnPropertyNames(constructor.prototype)
44
+ .filter(shouldSpy(constructor.prototype))
45
+ .forEach((p) => constructor['_test'].spy(constructor.prototype, p));
46
+ }
47
+ /**
48
+ * Resets items tracked during testing such as calls to spied functions.
49
+ * Must be called at the end of every test even if not asserting on the spies.
50
+ * @param wrapper - `WithTestHarness<T>` object to reset
51
+ * @public
52
+ */
53
+ export function resetTestHarness(wrapper) {
54
+ wrapper.constructor['_test'].restore();
55
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './logger';
2
- //# sourceMappingURL=index.js.map
2
+ export * from './harness';
3
+ export * from './types';
@@ -6,4 +6,3 @@ import { createLogger } from '@genesislcap/foundation-utils';
6
6
  * Exported so you can set log levels differently across packages when needed.
7
7
  */
8
8
  export const logger = createLogger('foundation-testing');
9
- //# sourceMappingURL=logger.js.map
@@ -0,0 +1,2 @@
1
+ // https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts
2
+ export {};
@@ -1,2 +1 @@
1
1
  export * from './uvu';
2
- //# sourceMappingURL=index.js.map
@@ -5,4 +5,3 @@ import * as assert from 'uvu/assert';
5
5
  * @public
6
6
  */
7
7
  export { assert, suite, test };
8
- //# sourceMappingURL=uvu.js.map