@gitlab/frontend-tests 0.1.3 → 0.1.5-rc.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/README.md CHANGED
@@ -5,23 +5,23 @@ Reusable test infrastructure for GitLab-owned frontend packages. It includes a s
5
5
  ## Installation
6
6
 
7
7
  ```sh
8
- yarn add --dev @gitlab/frontend-tests
8
+ pnpm add -D @gitlab/frontend-tests
9
9
  ```
10
10
 
11
11
  ## Development
12
12
 
13
- The package is written in TypeScript and built with rollup. Tests use vitest. Linting uses ESLint 9 with a flat config and typescript-eslint.
13
+ The package is written in TypeScript and built with rollup. Tests use Rstest. Linting uses ESLint 9 with a flat config and typescript-eslint.
14
14
 
15
- `tsconfig.json` is the editor and `yarn typecheck` config and covers the tests. `tsconfig.build.json` extends it for rollup and excludes the tests so they stay out of `dist/`.
15
+ `tsconfig.json` is the editor and `pnpm typecheck` config and covers the tests. `tsconfig.build.json` extends it for rollup and excludes the tests so they stay out of `dist/`.
16
16
 
17
17
  Relative imports in `src/` carry a `.js` extension (`./types.js`), which TypeScript maps to the `.ts` source. The emitted `.d.ts` files keep those specifiers, which `node16` module resolution requires. After rollup, `scripts/emit_cjs_types.mjs` copies every `.d.ts` to a `.d.cts` twin for the `require` export condition, so CommonJS TypeScript consumers resolve types too. `lodash-es` is bundled into `dist/` because it ships ESM only; the only runtime dependency is `@whatwg-node/fetch`.
18
18
 
19
19
  ```sh
20
- yarn install # install dependencies
21
- yarn test # run tests
22
- yarn build # build dist/ (ESM, CJS and .d.ts)
23
- yarn lint # run ESLint
24
- yarn typecheck # run tsc --noEmit
20
+ pnpm install # install dependencies
21
+ pnpm test # run tests
22
+ pnpm build # build dist/ (ESM, CJS and .d.ts)
23
+ pnpm lint # run ESLint
24
+ pnpm typecheck # run tsc --noEmit
25
25
  ```
26
26
 
27
27
  ## Adding a module
@@ -93,11 +93,14 @@ The `publish` job runs only on git tags that match `v<digits>`, for example `v0.
93
93
 
94
94
  To release:
95
95
 
96
- 1. Bump `version` in `package.json` in a merge request.
97
- 2. Merge the merge request.
98
- 3. Create and push a tag `vX.Y.Z` on `main`. The tag must match the version.
96
+ 1. Merge your changes to `main`.
97
+ 2. Create and push a tag `vX.Y.Z` on `main`.
99
98
 
100
- The tag pipeline publishes the package.
99
+ The tag pipeline publishes the package. The `publish` job sets `version` in `package.json` from the tag before publishing, so no version-bump merge request is needed. Releases do not update the committed `version`; the tag is authoritative. `package.json` carries the placeholder `0.0.0-development`, which is never published. Do not bump it by hand. To check what is released, run `npm view @gitlab/frontend-tests version`, or look at the latest release on the project overview.
100
+
101
+ After `publish` succeeds, the `release` job creates a GitLab release for the tag, with a one-line description and a link to the npm package. It does not run if `publish` fails, so a release always means the version is on npm.
102
+
103
+ Tags must be `vMAJOR.MINOR.PATCH`, with an optional prerelease suffix (for example `v1.0.0-rc.1`), or the `publish` job fails. Stable versions are published with the `latest` dist-tag; prerelease versions (those containing `-`) use the `next` dist-tag so they do not replace the stable release for consumers installing without a version or tag.
101
104
 
102
105
  ### One-time setup
103
106
 
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var server = require('./server-Bv38oMzv.cjs');
3
+ var server = require('./server-erJjAkSH.cjs');
4
4
  require('msw/node');
5
5
  require('msw');
6
6
  require('node:fs');
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { a as activateVariant, b as baseMetadata, c as buildHandlers, d as captureMissingOperation, e as captureRequest, f as capturedRequests, g as clearMissingOperations, h as createFixturePaginator, i as createServer, j as defineFixtureVariants, k as defineRestFixtureVariants, l as dumpRegistry, m as expectGraphQLCalls, n as getActiveVariant, o as getVariant, p as isValidGraphqlFixture, q as lastRequestVariables, r as loadFixturesMap, s as mapStaticOperationHandlers, t as matchFixture, u as missingOperations, v as normaliseGraphqlFixture, w as resetAllVariants, x as resetCapturedRequests, y as setFixtureData, z as setFixtureErrors, A as setFixtureItemsCount, B as setQueryVariant, C as snapshotRequests } from './server-CrJeYlNb.js';
1
+ export { a as activateVariant, b as baseMetadata, c as buildHandlers, d as captureMissingOperation, e as captureRequest, f as capturedRequests, g as clearMissingOperations, h as createFixturePaginator, i as createServer, j as defineFixtureVariants, k as defineRestFixtureVariants, l as dumpRegistry, m as expectGraphQLCalls, n as getActiveVariant, o as getVariant, p as isValidGraphqlFixture, q as lastRequestVariables, r as loadFixturesMap, s as mapStaticOperationHandlers, t as matchFixture, u as missingOperations, v as normaliseGraphqlFixture, w as resetAllVariants, x as resetCapturedRequests, y as setFixtureData, z as setFixtureErrors, A as setFixtureItemsCount, B as setQueryVariant, C as snapshotRequests } from './server-BOfJGLQi.js';
2
2
  import 'msw/node';
3
3
  import 'msw';
4
4
  import 'node:fs';
@@ -16,8 +16,9 @@ export declare function mapStaticOperationHandlers<Fixture>(fixtures: Record<str
16
16
  /**
17
17
  * Assembles the MSW handlers for a test run from the feature handlers and REST
18
18
  * endpoints a consumer registers. Every answered request is captured for
19
- * assertions. A GraphQL operation nobody answers is recorded as missing and fails
20
- * with a 400, and an unknown REST URL is logged and fails the same way, so a gap in
21
- * the handlers surfaces as a loud test failure instead of a silent empty response.
19
+ * assertions. A GraphQL operation or REST GET that nothing answers gets a 400 and
20
+ * is recorded in `missingOperations`. Consumers report that set after the suite,
21
+ * so a missing handler fails the run even when the app swallows the 400. Other
22
+ * REST methods with no endpoint fall through to the consumer's `onUnhandledRequest`.
22
23
  */
23
24
  export declare function buildHandlers(allFeatureHandlers: FeatureHandler[], allRestEndpoints: RestEndpoint[]): RequestHandler[];
@@ -16,8 +16,9 @@ export declare function mapStaticOperationHandlers<Fixture>(fixtures: Record<str
16
16
  /**
17
17
  * Assembles the MSW handlers for a test run from the feature handlers and REST
18
18
  * endpoints a consumer registers. Every answered request is captured for
19
- * assertions. A GraphQL operation nobody answers is recorded as missing and fails
20
- * with a 400, and an unknown REST URL is logged and fails the same way, so a gap in
21
- * the handlers surfaces as a loud test failure instead of a silent empty response.
19
+ * assertions. A GraphQL operation or REST GET that nothing answers gets a 400 and
20
+ * is recorded in `missingOperations`. Consumers report that set after the suite,
21
+ * so a missing handler fails the run even when the app swallows the 400. Other
22
+ * REST methods with no endpoint fall through to the consumer's `onUnhandledRequest`.
22
23
  */
23
24
  export declare function buildHandlers(allFeatureHandlers: FeatureHandler[], allRestEndpoints: RestEndpoint[]): RequestHandler[];
@@ -1,7 +1,8 @@
1
1
  import type { CapturedRequest, GraphqlVariables, RequestCounts } from './types.cjs';
2
2
  /**
3
- * Every GraphQL operation a test triggered that no handler answered, collected across
4
- * the run so a new suite shows all the handlers it still needs in one go.
3
+ * Every GraphQL operation ("opname") and REST GET ("GET xyz") a test triggered
4
+ * that no handler answered, collected across the run so a new suite shows all
5
+ * the handlers it still needs in one go.
5
6
  */
6
7
  export declare const missingOperations: Set<string>;
7
8
  /** Records an operation no handler answered, so it shows up in the run's summary of missing handlers. */
@@ -1,7 +1,8 @@
1
1
  import type { CapturedRequest, GraphqlVariables, RequestCounts } from './types.js';
2
2
  /**
3
- * Every GraphQL operation a test triggered that no handler answered, collected across
4
- * the run so a new suite shows all the handlers it still needs in one go.
3
+ * Every GraphQL operation ("opname") and REST GET ("GET xyz") a test triggered
4
+ * that no handler answered, collected across the run so a new suite shows all
5
+ * the handlers it still needs in one go.
5
6
  */
6
7
  export declare const missingOperations: Set<string>;
7
8
  /** Records an operation no handler answered, so it shows up in the run's summary of missing handlers. */
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var server = require('./server-Bv38oMzv.cjs');
3
+ var server = require('./server-erJjAkSH.cjs');
4
4
  require('msw/node');
5
5
  require('msw');
6
6
  require('node:fs');
@@ -1,4 +1,4 @@
1
- export { a as activateVariant, b as baseMetadata, c as buildHandlers, d as captureMissingOperation, e as captureRequest, f as capturedRequests, g as clearMissingOperations, h as createFixturePaginator, i as createServer, j as defineFixtureVariants, k as defineRestFixtureVariants, l as dumpRegistry, m as expectGraphQLCalls, n as getActiveVariant, o as getVariant, p as isValidGraphqlFixture, q as lastRequestVariables, r as loadFixturesMap, s as mapStaticOperationHandlers, t as matchFixture, u as missingOperations, v as normaliseGraphqlFixture, w as resetAllVariants, x as resetCapturedRequests, y as setFixtureData, z as setFixtureErrors, A as setFixtureItemsCount, B as setQueryVariant, C as snapshotRequests } from './server-CrJeYlNb.js';
1
+ export { a as activateVariant, b as baseMetadata, c as buildHandlers, d as captureMissingOperation, e as captureRequest, f as capturedRequests, g as clearMissingOperations, h as createFixturePaginator, i as createServer, j as defineFixtureVariants, k as defineRestFixtureVariants, l as dumpRegistry, m as expectGraphQLCalls, n as getActiveVariant, o as getVariant, p as isValidGraphqlFixture, q as lastRequestVariables, r as loadFixturesMap, s as mapStaticOperationHandlers, t as matchFixture, u as missingOperations, v as normaliseGraphqlFixture, w as resetAllVariants, x as resetCapturedRequests, y as setFixtureData, z as setFixtureErrors, A as setFixtureItemsCount, B as setQueryVariant, C as snapshotRequests } from './server-BOfJGLQi.js';
2
2
  import 'msw/node';
3
3
  import 'msw';
4
4
  import 'node:fs';
@@ -3277,8 +3277,9 @@ function set(object, path, value) {
3277
3277
  }
3278
3278
 
3279
3279
  /**
3280
- * Every GraphQL operation a test triggered that no handler answered, collected across
3281
- * the run so a new suite shows all the handlers it still needs in one go.
3280
+ * Every GraphQL operation ("opname") and REST GET ("GET xyz") a test triggered
3281
+ * that no handler answered, collected across the run so a new suite shows all
3282
+ * the handlers it still needs in one go.
3282
3283
  */
3283
3284
  const missingOperations = new Set();
3284
3285
  /** Records an operation no handler answered, so it shows up in the run's summary of missing handlers. */
@@ -3948,9 +3949,10 @@ function mapStaticOperationHandlers(fixtures) {
3948
3949
  /**
3949
3950
  * Assembles the MSW handlers for a test run from the feature handlers and REST
3950
3951
  * endpoints a consumer registers. Every answered request is captured for
3951
- * assertions. A GraphQL operation nobody answers is recorded as missing and fails
3952
- * with a 400, and an unknown REST URL is logged and fails the same way, so a gap in
3953
- * the handlers surfaces as a loud test failure instead of a silent empty response.
3952
+ * assertions. A GraphQL operation or REST GET that nothing answers gets a 400 and
3953
+ * is recorded in `missingOperations`. Consumers report that set after the suite,
3954
+ * so a missing handler fails the run even when the app swallows the 400. Other
3955
+ * REST methods with no endpoint fall through to the consumer's `onUnhandledRequest`.
3954
3956
  */
3955
3957
  function buildHandlers(allFeatureHandlers, allRestEndpoints) {
3956
3958
  const restEndpointsHandlers = allRestEndpoints.map((endpoint) => http[endpoint.method](endpoint.path, ({ request }) => {
@@ -3975,8 +3977,7 @@ function buildHandlers(allFeatureHandlers, allRestEndpoints) {
3975
3977
  }),
3976
3978
  ...restEndpointsHandlers,
3977
3979
  http.get('*', ({ request }) => {
3978
- // eslint-disable-next-line no-console
3979
- console.log(`Unhandled url for REST endpoint: ${request.url}`);
3980
+ captureMissingOperation(`GET ${new URL(request.url).pathname}`);
3980
3981
  return new HttpResponse(null, { status: 400 });
3981
3982
  }),
3982
3983
  ];
@@ -3279,8 +3279,9 @@ function set(object, path, value) {
3279
3279
  }
3280
3280
 
3281
3281
  /**
3282
- * Every GraphQL operation a test triggered that no handler answered, collected across
3283
- * the run so a new suite shows all the handlers it still needs in one go.
3282
+ * Every GraphQL operation ("opname") and REST GET ("GET xyz") a test triggered
3283
+ * that no handler answered, collected across the run so a new suite shows all
3284
+ * the handlers it still needs in one go.
3284
3285
  */
3285
3286
  const missingOperations = new Set();
3286
3287
  /** Records an operation no handler answered, so it shows up in the run's summary of missing handlers. */
@@ -3950,9 +3951,10 @@ function mapStaticOperationHandlers(fixtures) {
3950
3951
  /**
3951
3952
  * Assembles the MSW handlers for a test run from the feature handlers and REST
3952
3953
  * endpoints a consumer registers. Every answered request is captured for
3953
- * assertions. A GraphQL operation nobody answers is recorded as missing and fails
3954
- * with a 400, and an unknown REST URL is logged and fails the same way, so a gap in
3955
- * the handlers surfaces as a loud test failure instead of a silent empty response.
3954
+ * assertions. A GraphQL operation or REST GET that nothing answers gets a 400 and
3955
+ * is recorded in `missingOperations`. Consumers report that set after the suite,
3956
+ * so a missing handler fails the run even when the app swallows the 400. Other
3957
+ * REST methods with no endpoint fall through to the consumer's `onUnhandledRequest`.
3956
3958
  */
3957
3959
  function buildHandlers(allFeatureHandlers, allRestEndpoints) {
3958
3960
  const restEndpointsHandlers = allRestEndpoints.map((endpoint) => msw.http[endpoint.method](endpoint.path, ({ request }) => {
@@ -3977,8 +3979,7 @@ function buildHandlers(allFeatureHandlers, allRestEndpoints) {
3977
3979
  }),
3978
3980
  ...restEndpointsHandlers,
3979
3981
  msw.http.get('*', ({ request }) => {
3980
- // eslint-disable-next-line no-console
3981
- console.log(`Unhandled url for REST endpoint: ${request.url}`);
3982
+ captureMissingOperation(`GET ${new URL(request.url).pathname}`);
3982
3983
  return new msw.HttpResponse(null, { status: 400 });
3983
3984
  }),
3984
3985
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/frontend-tests",
3
- "version": "0.1.3",
3
+ "version": "0.1.5-rc.0",
4
4
  "description": "Reusable test infrastructure for GitLab frontend packages",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -90,14 +90,6 @@
90
90
  "integration.js",
91
91
  "integration"
92
92
  ],
93
- "scripts": {
94
- "build": "rollup -c && node scripts/emit_cjs_types.mjs",
95
- "test": "vitest run",
96
- "test:watch": "vitest",
97
- "lint": "eslint src/",
98
- "typecheck": "tsc --noEmit",
99
- "prepublishOnly": "yarn build"
100
- },
101
93
  "dependencies": {
102
94
  "@whatwg-node/fetch": "^0.10.11"
103
95
  },
@@ -111,22 +103,20 @@
111
103
  }
112
104
  },
113
105
  "devDependencies": {
114
- "@eslint/js": "^9.0.0",
106
+ "@gitlab/frontend-config": "^0.1.1",
115
107
  "@jest/types": "^30.5.1",
116
108
  "@rollup/plugin-commonjs": "^29.0.3",
117
109
  "@rollup/plugin-node-resolve": "^16.0.3",
118
110
  "@rollup/plugin-typescript": "^12.3.0",
111
+ "@rstest/core": "^0.12.5",
119
112
  "@types/lodash-es": "^4.17.12",
120
113
  "@types/node": "^20",
121
114
  "eslint": "^9.0.0",
122
- "globals": "^17.7.0",
123
115
  "lodash-es": "^4.17.23",
124
116
  "msw": "^2.15.0",
125
117
  "rollup": "^4.0.0",
126
118
  "tslib": "^2.8.1",
127
- "typescript": "~5.8.0",
128
- "typescript-eslint": "^8.71.0",
129
- "vitest": "^3.0.0"
119
+ "typescript": "~5.8.0"
130
120
  },
131
121
  "engines": {
132
122
  "node": ">=20"
@@ -137,5 +127,12 @@
137
127
  },
138
128
  "publishConfig": {
139
129
  "registry": "https://registry.npmjs.org/"
130
+ },
131
+ "scripts": {
132
+ "build": "rollup -c && node scripts/emit_cjs_types.mjs",
133
+ "test": "rstest",
134
+ "test:watch": "rstest watch",
135
+ "lint": "eslint src/",
136
+ "typecheck": "tsc --noEmit"
140
137
  }
141
- }
138
+ }