From ad521af670ebbe223d7949d51c2fc52a581c6c70 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Mon, 1 Nov 2021 15:22:37 +0100 Subject: [PATCH] Graduate shared workers to be non-experimental --- docs/recipes/shared-workers.md | 82 +++++++------- lib/load-config.js | 4 +- lib/plugin-support/shared-worker-loader.js | 4 +- lib/worker/plugin.cjs | 7 +- plugin.d.ts | 100 +++++++++--------- test-d/plugin.ts | 4 +- .../fixtures/_worker.js | 2 +- .../fixtures/package.json | 7 +- .../fixtures/test.js | 2 +- .../is-an-experiment/fixtures/package.json | 3 - .../is-an-experiment/fixtures/test.js | 5 - .../is-an-experiment/snapshots/test.js.md | 11 -- .../is-an-experiment/snapshots/test.js.snap | Bin 162 -> 0 bytes test/shared-workers/is-an-experiment/test.js | 11 -- .../lifecycle/fixtures/_worker.js | 2 +- .../lifecycle/fixtures/available.js | 2 +- .../lifecycle/fixtures/package.json | 5 +- .../lifecycle/fixtures/teardown.js | 4 +- .../fixtures/_worker.js | 2 +- .../fixtures/package.json | 7 +- .../fixtures/test.js | 2 +- .../fixtures/in-shared-worker.js | 2 +- .../fixtures/package.json | 5 +- .../fixtures/_plugin.js | 2 +- .../fixtures/_worker.js | 2 +- .../fixtures/package.json | 7 +- .../worker-protocol/fixtures/_plugin.js | 2 +- .../worker-protocol/fixtures/_worker.js | 2 +- .../worker-protocol/fixtures/package.json | 7 +- .../fixtures/factory-function.js | 2 +- .../worker-startup-crashes/fixtures/module.js | 2 +- .../fixtures/no-factory-function.js | 2 +- .../fixtures/package.json | 5 +- .../fixtures/_plugin.js | 2 +- .../fixtures/_worker.js | 2 +- .../fixtures/package.json | 5 +- 36 files changed, 122 insertions(+), 193 deletions(-) delete mode 100644 test/shared-workers/is-an-experiment/fixtures/package.json delete mode 100644 test/shared-workers/is-an-experiment/fixtures/test.js delete mode 100644 test/shared-workers/is-an-experiment/snapshots/test.js.md delete mode 100644 test/shared-workers/is-an-experiment/snapshots/test.js.snap delete mode 100644 test/shared-workers/is-an-experiment/test.js diff --git a/docs/recipes/shared-workers.md b/docs/recipes/shared-workers.md index f7c7effc9..451a84263 100644 --- a/docs/recipes/shared-workers.md +++ b/docs/recipes/shared-workers.md @@ -1,10 +1,10 @@ # Extending AVA using shared workers -Shared workers are a new, powerful (and experimental) AVA feature. A program can be loaded in a [worker thread](https://nodejs.org/docs/latest/api/worker_threads.html) in AVA's main process and then communicate with code running in the test workers. This enables your tests to better utilize shared resources during a test run, as well as providing opportunities to set up these resources before tests start (or clean them up after). +Shared workers are a powerful AVA feature. A program can be loaded in a [worker thread](https://nodejs.org/docs/latest/api/worker_threads.html) in AVA's main process and then communicate with code running in the test workers. This enables your tests to better utilize shared resources during a test run, as well as providing opportunities to set up these resources before tests start (or clean them up after). When you use watch mode, shared workers remain loaded across runs. -## Enabling the experiment +## Enabling the experiment (only needed with AVA 3) Shared workers are available when you use AVA with Node.js 12.17.0 or newer. AVA 3.13.0 or newer is required. It is an experimental feature so you need to enable it in your AVA configuration: @@ -31,20 +31,20 @@ Here we'll discuss building low-level plugins. ### Registering a shared worker -Plugins are registered inside test workers. They'll provide the path for the main program, which AVA will load in a [worker thread](https://nodejs.org/docs/latest/api/worker_threads.html) in its main process. For each unique path one worker thread is started. +Plugins are registered inside test workers. They'll provide the path for the shared worker, which AVA will load in a [worker thread](https://nodejs.org/docs/latest/api/worker_threads.html) in its main process. For each unique path one worker thread is started. -Plugins communicate with their main program using a *protocol*. Protocols are versioned independently from AVA itself. This allows us to make improvements without breaking existing plugins. Protocols are only removed in major AVA releases. +Plugins communicate with their shared worker using a *protocol*. Protocols are versioned independently from AVA itself. This allows us to make improvements without breaking existing plugins. Protocols are only removed in major AVA releases. Plugins can be compatible with multiple protocols. AVA will select the best protocol it supports. If AVA does not support any of the specified protocols it'll throw an error. The selected protocol is available on the returned worker object. -**While shared workers are experimental, there is only an unversioned *experimental* protocol. Breaking changes may occur with any AVA release.** +**For AVA 3, substitute `'ava4'` with `'experimental'`.** ```js -const {registerSharedWorker} = require('ava/plugin'); +import {registerSharedWorker} from 'ava/plugin'; const shared = registerSharedWorker({ filename: path.resolve(__dirname, 'worker.js'), - supportedProtocols: ['experimental'] + supportedProtocols: ['ava4'] }); ``` @@ -55,61 +55,61 @@ You can supply a `teardown()` function which will be called after all tests have ```js const worker = registerSharedWorker({ filename: path.resolve(__dirname, 'worker.js'), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], teardown () { // Perform any clean-up within the test process itself. } }); ``` -You can also provide some data passed to the main program when it is loaded. Of course, it is only loaded once, so this is only useful in limited circumstances: +You can also provide some data passed to the shared worker when it is loaded. Of course, it is only loaded once, so this is only useful in limited circumstances: ```js const shared = registerSharedWorker({ filename: path.resolve(__dirname, 'worker.js'), initialData: {hello: 'world'}, - supportedProtocols: ['experimental'] + supportedProtocols: ['ava4'] }); ``` -On this `shared` object, `protocol` is set to the selected protocol. Since the main program is loaded asynchronously, `available` provides a promise that fulfils when the main program first becomes available. `currentlyAvailable` reflects whether the worker is, well, currently available. +On this `shared` object, `protocol` is set to the selected protocol. Since the shared worker is loaded asynchronously, `available` provides a promise that fulfils when the shared worker first becomes available. `currentlyAvailable` reflects whether the worker is, well, currently available. There are two more methods available on the `shared` object, which we'll get to soon. -#### Initializing the main program +#### Initializing the shared worker -AVA loads the main program (as identified through the `filename` option) in a worker thread. The program must export a factory method. For CJS programs this can be done by assigning `module.exports` or `exports.default`. For ESM programs you must use `export default`. If the `filename` to an ESM program is an absolute path it must be specified using the `file:` protocol. +AVA loads the shared worker (as identified through the `filename` option) in a worker thread. This must be an ES module file with a default export. The filename must be an absolute path using the `file:` protocol or a `URL` instance. -Like when calling `registerSharedWorker()`, the factory method must negotiate a protocol: +The default export must be a factory method. Like when calling `registerSharedWorker()`, it must negotiate a protocol: ```js -exports.default = ({negotiateProtocol}) => { - const main = negotiateProtocol(['experimental']); -}; +export default ({negotiateProtocol}) => { + const main = negotiateProtocol(['ava4']); +} ``` On this `main` object, `protocol` is set to the selected protocol. `initialData` holds the data provided when the worker was first registered. -When you're done initializing the main program you must call `main.ready()`. This makes the worker available in test workers. You can call `main.ready()` asynchronously. +When you're done initializing the shared worker you must call `main.ready()`. This makes the worker available in test workers. You can call `main.ready()` asynchronously. Any errors thrown by the factory method will crash the worker thread and make the worker unavailable in test workers. The same goes for unhandled rejections. The factory method may return a promise. -### Communicating between test workers and the worker thread +### Communicating between test workers and the shared worker -AVA's low-level shared worker infrastructure is primarily about communication. You can send messages from test workers to the shared worker thread, and the other way around. Higher-level logic can be implemented on top of this message passing infrastructure. +AVA's low-level shared worker infrastructure is primarily about communication. You can send messages from test workers to the shared worker, and the other way around. Higher-level logic can be implemented on top of this message passing infrastructure. Message data is serialized using the [V8 Serialization API](https://nodejs.org/docs/latest-v12.x/api/v8.html#v8_serialization_api). Please read up on some [important limitations](https://nodejs.org/docs/latest-v12.x/api/worker_threads.html#worker_threads_port_postmessage_value_transferlist). -In the main program you can subscribe to messages from test workers: +In the shared worker you can subscribe to messages from test workers: ```js -exports.default = async ({negotiateProtocol}) => { - const main = negotiateProtocol(['experimental']).ready(); +export default async ({negotiateProtocol}) => { + const main = negotiateProtocol(['ava4']).ready(); for await (const message of main.subscribe()) { // … } -}; +} ``` Messages have IDs that are unique for the main AVA process. Across AVA runs you may see the same ID. Access the ID using the `id` property. @@ -121,8 +121,8 @@ You can reply to a received message by calling `reply()`. This publishes a messa To illustrate this here's a "game" of Marco Polo: ```js -exports.default = ({negotiateProtocol}) => { - const main = negotiateProtocol(['experimental']).ready(); +export default ({negotiateProtocol}) => { + const main = negotiateProtocol(['ava4']).ready(); play(main.subscribe()); }; @@ -134,7 +134,7 @@ const play = async (messages) => { play(response.replies()); } } -}; +} ``` (Of course this sets up many reply listeners which is rather inefficient.) @@ -142,15 +142,15 @@ const play = async (messages) => { You can also broadcast messages to all connected test workers: ```js -exports.default = async ({negotiateProtocol}) => { - const main = negotiateProtocol(['experimental']).ready(); +export default async ({negotiateProtocol}) => { + const main = negotiateProtocol(['ava4']).ready(); for await (const message of main.subscribe()) { if (message.data === 'Bingo!') { main.broadcast('Bingo!'); } } -}; +} ``` Like with `reply()`, `broadcast()` returns a published message which can receive replies. Call `replies()` to get an asynchronous iterator for reply messages. @@ -162,13 +162,13 @@ These test workers have a unique ID (which, like message IDs, is unique for the Of course you don't need to wait for a message *from* a test worker to access this object. Use `main.testWorkers()` to get an asynchronous iterator which produces each newly connected test worker: ```js -exports.default = async ({negotiateProtocol}) => { - const main = negotiateProtocol(['experimental']).ready(); +export default async ({negotiateProtocol}) => { + const main = negotiateProtocol(['ava4']).ready(); for await (const testWorker of main.testWorkers()) { main.broadcast(`New test file: ${testWorker.file}`); } -}; +} ``` Within test workers, once the shared worker is available, you can publish messages: @@ -197,22 +197,22 @@ Messages are always produced in their own turn of the event loop. This means you ### Cleaning up resources -Test workers come and go while the worker thread remains. It's therefore important to clean up resources. +Test workers come and go while the shared worker remains. It's therefore important to clean up resources. Messages are subscribed to using async iterators. These return when the test worker exits. You can register teardown functions to be run when the test worker exits: ```js -exports.default = async ({negotiateProtocol}) => { - const main = negotiateProtocol(['experimental']).ready(); +export default async ({negotiateProtocol}) => { + const main = negotiateProtocol(['ava4']).ready(); for await (const testWorker of main.testWorkers()) { testWorker.teardown(() => { // Bye bye… }); } -}; +} ``` The most recently registered function is called first, and so forth. Functions execute sequentially. @@ -220,8 +220,8 @@ The most recently registered function is called first, and so forth. Functions e More interestingly, a wrapped teardown function is returned so that you can call it manually. AVA still ensures the function only runs once. ```js -exports.default = ({negotiateProtocol}) => { - const main = negotiateProtocol(['experimental']).ready(); +export default ({negotiateProtocol}) => { + const main = negotiateProtocol(['ava4']).ready(); for await (const worker of testWorkers) { counters.set(worker, 0); @@ -231,7 +231,7 @@ exports.default = ({negotiateProtocol}) => { waitForTen(worker.subscribe(), teardown); } -}; +} const counters = new WeakMap(); @@ -255,4 +255,4 @@ Not sure what to build? Previously folks have expressed a desire for mutexes, ma We could also extend the shared worker implementation in AVA itself. Perhaps so you can run code before a new test run, even with watch mode. Or so you can initialize a shared worker based on the AVA configuration, not when a test file runs. -Please [comment here](https://github.com/avajs/ava/issues/2605) with ideas, questions and feedback. +Please [comment here](https://github.com/avajs/ava/discussions/2703) with ideas, questions and feedback. diff --git a/lib/load-config.js b/lib/load-config.js index 2ed77119a..1748b91b2 100644 --- a/lib/load-config.js +++ b/lib/load-config.js @@ -8,9 +8,7 @@ import {packageConfig, packageJsonPath} from 'pkg-conf'; const NO_SUCH_FILE = Symbol('no ava.config.js file'); const MISSING_DEFAULT_EXPORT = Symbol('missing default export'); -const EXPERIMENTS = new Set([ - 'sharedWorkers', -]); +const EXPERIMENTS = new Set(); const importConfig = async ({configFile, fileForErrorMessage}) => { const {default: config = MISSING_DEFAULT_EXPORT} = await import(url.pathToFileURL(configFile)); // eslint-disable-line node/no-unsupported-features/es-syntax diff --git a/lib/plugin-support/shared-worker-loader.js b/lib/plugin-support/shared-worker-loader.js index ce9540f25..79ace6400 100644 --- a/lib/plugin-support/shared-worker-loader.js +++ b/lib/plugin-support/shared-worker-loader.js @@ -173,7 +173,7 @@ loadFactory(workerData.filename).then(factory => { factory({ negotiateProtocol(supported) { - if (!supported.includes('experimental')) { + if (!supported.includes('ava4')) { fatal = new Error(`This version of AVA (${pkg.version}) is not compatible with shared worker plugin at ${workerData.filename}`); throw fatal; } @@ -213,7 +213,7 @@ loadFactory(workerData.filename).then(factory => { return { initialData: workerData.initialData, - protocol: 'experimental', + protocol: 'ava4', ready() { signalAvailable(); diff --git a/lib/worker/plugin.cjs b/lib/worker/plugin.cjs index f62409fb3..92fef3c58 100644 --- a/lib/worker/plugin.cjs +++ b/lib/worker/plugin.cjs @@ -67,7 +67,7 @@ function createSharedWorker(filename, initialData, teardown) { return { available: channel.available, - protocol: 'experimental', + protocol: 'ava4', get currentlyAvailable() { return channel.currentlyAvailable; @@ -90,15 +90,12 @@ function registerSharedWorker({ teardown, }) { const options_ = options.get(); - if (!options_.experiments.sharedWorkers) { - throw new Error('Shared workers are experimental. Opt in to them in your AVA configuration'); - } if (!options_.workerThreads) { throw new Error('Shared workers can be used only when worker threads are enabled'); } - if (!supportedProtocols.includes('experimental')) { + if (!supportedProtocols.includes('ava4')) { throw new Error(`This version of AVA (${pkg.version}) does not support any of the desired shared worker protocols: ${supportedProtocols.join(',')}`); } diff --git a/plugin.d.ts b/plugin.d.ts index 08351dc34..c4dfd8357 100644 --- a/plugin.d.ts +++ b/plugin.d.ts @@ -1,50 +1,48 @@ import {URL} from 'node:url'; export namespace SharedWorker { - export type ProtocolIdentifier = 'experimental'; + export type ProtocolIdentifier = 'ava4'; export type FactoryOptions = { - negotiateProtocol (supported: readonly ['experimental']): Experimental.Protocol; + negotiateProtocol (supported: readonly ['ava4']): Protocol; // Add overloads for additional protocols. }; export type Factory = (options: FactoryOptions) => void; - export namespace Experimental { - export type Protocol = { - readonly initialData: Data; - readonly protocol: 'experimental'; - broadcast: (data: Data) => BroadcastMessage; - ready: () => Protocol; - subscribe: () => AsyncIterableIterator>; - testWorkers: () => AsyncIterableIterator>; - }; + export type Protocol = { + readonly initialData: Data; + readonly protocol: 'ava4'; + broadcast: (data: Data) => BroadcastMessage; + ready: () => Protocol; + subscribe: () => AsyncIterableIterator>; + testWorkers: () => AsyncIterableIterator>; + }; - export type BroadcastMessage = { - readonly id: string; - replies: () => AsyncIterableIterator>; - }; + export type BroadcastMessage = { + readonly id: string; + replies: () => AsyncIterableIterator>; + }; - export type PublishedMessage = { - readonly id: string; - replies: () => AsyncIterableIterator>; - }; + export type PublishedMessage = { + readonly id: string; + replies: () => AsyncIterableIterator>; + }; - export type ReceivedMessage = { - readonly data: Data; - readonly id: string; - readonly testWorker: TestWorker; - reply: (data: Data) => PublishedMessage; - }; + export type ReceivedMessage = { + readonly data: Data; + readonly id: string; + readonly testWorker: TestWorker; + reply: (data: Data) => PublishedMessage; + }; - export type TestWorker = { - readonly id: string; - readonly file: string; - publish: (data: Data) => PublishedMessage; - subscribe: () => AsyncIterableIterator>; - teardown: void> (fn: TeardownFn) => TeardownFn; - }; - } + export type TestWorker = { + readonly id: string; + readonly file: string; + publish: (data: Data) => PublishedMessage; + subscribe: () => AsyncIterableIterator>; + teardown: void> (fn: TeardownFn) => TeardownFn; + }; export namespace Plugin { export type RegistrationOptions = { @@ -54,28 +52,26 @@ export namespace SharedWorker { readonly teardown?: () => void; }; - export namespace Experimental { - export type Protocol = { - readonly available: Promise; - readonly currentlyAvailable: boolean; - readonly protocol: 'experimental'; - publish: (data: Data) => PublishedMessage; - subscribe: () => AsyncIterableIterator>; - }; + export type Protocol = { + readonly available: Promise; + readonly currentlyAvailable: boolean; + readonly protocol: 'ava4'; + publish: (data: Data) => PublishedMessage; + subscribe: () => AsyncIterableIterator>; + }; - export type PublishedMessage = { - readonly id: string; - replies: () => AsyncIterableIterator>; - }; + export type PublishedMessage = { + readonly id: string; + replies: () => AsyncIterableIterator>; + }; - export type ReceivedMessage = { - readonly data: Data; - readonly id: string; - reply: (data: Data) => PublishedMessage; - }; - } + export type ReceivedMessage = { + readonly data: Data; + readonly id: string; + reply: (data: Data) => PublishedMessage; + }; } } -export function registerSharedWorker(options: SharedWorker.Plugin.RegistrationOptions<'experimental', Data>): SharedWorker.Plugin.Experimental.Protocol; +export function registerSharedWorker(options: SharedWorker.Plugin.RegistrationOptions<'ava4', Data>): SharedWorker.Plugin.Protocol; // Add overloads for additional protocols. diff --git a/test-d/plugin.ts b/test-d/plugin.ts index 8a4099714..44e0ae40a 100644 --- a/test-d/plugin.ts +++ b/test-d/plugin.ts @@ -2,8 +2,8 @@ import {expectType} from 'tsd'; import * as plugin from '../plugin'; // eslint-disable-line import/extensions -expectType(plugin.registerSharedWorker({filename: '', supportedProtocols: ['experimental']})); +expectType(plugin.registerSharedWorker({filename: '', supportedProtocols: ['ava4']})); const factory: plugin.SharedWorker.Factory = ({negotiateProtocol}) => { // eslint-disable-line @typescript-eslint/no-unused-vars - expectType(negotiateProtocol(['experimental'])); + expectType(negotiateProtocol(['ava4'])); }; diff --git a/test/shared-workers/cannot-publish-before-available/fixtures/_worker.js b/test/shared-workers/cannot-publish-before-available/fixtures/_worker.js index 577a89d9b..a8e664121 100644 --- a/test/shared-workers/cannot-publish-before-available/fixtures/_worker.js +++ b/test/shared-workers/cannot-publish-before-available/fixtures/_worker.js @@ -1,3 +1,3 @@ export default async ({negotiateProtocol}) => { - negotiateProtocol(['experimental']).ready(); + negotiateProtocol(['ava4']).ready(); }; diff --git a/test/shared-workers/cannot-publish-before-available/fixtures/package.json b/test/shared-workers/cannot-publish-before-available/fixtures/package.json index 82e3ddfc8..bedb411a9 100644 --- a/test/shared-workers/cannot-publish-before-available/fixtures/package.json +++ b/test/shared-workers/cannot-publish-before-available/fixtures/package.json @@ -1,8 +1,3 @@ { - "type": "module", - "ava": { - "nonSemVerExperiments": { - "sharedWorkers": true - } - } + "type": "module" } diff --git a/test/shared-workers/cannot-publish-before-available/fixtures/test.js b/test/shared-workers/cannot-publish-before-available/fixtures/test.js index 2ed9aa4e0..47a625112 100644 --- a/test/shared-workers/cannot-publish-before-available/fixtures/test.js +++ b/test/shared-workers/cannot-publish-before-available/fixtures/test.js @@ -4,7 +4,7 @@ import * as plugin from 'ava/plugin'; test('cannot publish before ready', t => { const worker = plugin.registerSharedWorker({ filename: new URL('_worker.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); t.throws(() => worker.publish(), {message: 'Shared worker is not yet available'}); diff --git a/test/shared-workers/is-an-experiment/fixtures/package.json b/test/shared-workers/is-an-experiment/fixtures/package.json deleted file mode 100644 index bedb411a9..000000000 --- a/test/shared-workers/is-an-experiment/fixtures/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} diff --git a/test/shared-workers/is-an-experiment/fixtures/test.js b/test/shared-workers/is-an-experiment/fixtures/test.js deleted file mode 100644 index 2ed6f1472..000000000 --- a/test/shared-workers/is-an-experiment/fixtures/test.js +++ /dev/null @@ -1,5 +0,0 @@ -import * as plugin from 'ava/plugin'; - -plugin.registerSharedWorker({ - supportedProtocols: ['experimental'], -}); diff --git a/test/shared-workers/is-an-experiment/snapshots/test.js.md b/test/shared-workers/is-an-experiment/snapshots/test.js.md deleted file mode 100644 index e264b32e4..000000000 --- a/test/shared-workers/is-an-experiment/snapshots/test.js.md +++ /dev/null @@ -1,11 +0,0 @@ -# Snapshot report for `test/shared-workers/is-an-experiment/test.js` - -The actual snapshot is saved in `test.js.snap`. - -Generated by [AVA](https://avajs.dev). - -## opt-in is required - -> Snapshot 1 - - 'Shared workers are experimental. Opt in to them in your AVA configuration' diff --git a/test/shared-workers/is-an-experiment/snapshots/test.js.snap b/test/shared-workers/is-an-experiment/snapshots/test.js.snap deleted file mode 100644 index 265ada949054d019f938146d2cb17b9b298fff9a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 162 zcmZ<^b5sb~vkJ$@TQ7>&=y}N4XsOoU&XU zvjWrdvf@0G`sOv&J9avy&2#eH=j7>@rPmQTGd^m`1BquVCd`>XecH^ps3{SXX3l44 M_+_=KtsH1E0IQuo-v9sr diff --git a/test/shared-workers/is-an-experiment/test.js b/test/shared-workers/is-an-experiment/test.js deleted file mode 100644 index 349d85c48..000000000 --- a/test/shared-workers/is-an-experiment/test.js +++ /dev/null @@ -1,11 +0,0 @@ -import test from '@ava/test'; - -import {fixture} from '../../helpers/exec.js'; - -test('opt-in is required', async t => { - const result = await t.throwsAsync(fixture()); - t.is(result.exitCode, 1); - t.is(result.stats.uncaughtExceptions.length, 1); - t.snapshot(result.stats.uncaughtExceptions[0].message); -}); - diff --git a/test/shared-workers/lifecycle/fixtures/_worker.js b/test/shared-workers/lifecycle/fixtures/_worker.js index 1c7f791b8..cf71b7141 100644 --- a/test/shared-workers/lifecycle/fixtures/_worker.js +++ b/test/shared-workers/lifecycle/fixtures/_worker.js @@ -1,3 +1,3 @@ export default ({negotiateProtocol}) => { - negotiateProtocol(['experimental']).ready(); + negotiateProtocol(['ava4']).ready(); }; diff --git a/test/shared-workers/lifecycle/fixtures/available.js b/test/shared-workers/lifecycle/fixtures/available.js index 72f4309d2..4b5eef730 100644 --- a/test/shared-workers/lifecycle/fixtures/available.js +++ b/test/shared-workers/lifecycle/fixtures/available.js @@ -3,7 +3,7 @@ import * as plugin from 'ava/plugin'; const worker = plugin.registerSharedWorker({ filename: new URL('_worker.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); const availableImmediately = worker.currentlyAvailable; diff --git a/test/shared-workers/lifecycle/fixtures/package.json b/test/shared-workers/lifecycle/fixtures/package.json index 058b5540c..82d1f8494 100644 --- a/test/shared-workers/lifecycle/fixtures/package.json +++ b/test/shared-workers/lifecycle/fixtures/package.json @@ -3,9 +3,6 @@ "ava": { "files": [ "*" - ], - "nonSemVerExperiments": { - "sharedWorkers": true - } + ] } } diff --git a/test/shared-workers/lifecycle/fixtures/teardown.js b/test/shared-workers/lifecycle/fixtures/teardown.js index 328dd6eb5..6c6a52ced 100644 --- a/test/shared-workers/lifecycle/fixtures/teardown.js +++ b/test/shared-workers/lifecycle/fixtures/teardown.js @@ -6,7 +6,7 @@ import * as plugin from 'ava/plugin'; let calledLast = false; plugin.registerSharedWorker({ filename: new URL('_worker.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], teardown() { assert(calledLast); console.log('🤗TEARDOWN CALLED'); @@ -15,7 +15,7 @@ plugin.registerSharedWorker({ plugin.registerSharedWorker({ filename: new URL('_worker.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], teardown() { calledLast = true; }, diff --git a/test/shared-workers/restricted-to-worker-threads/fixtures/_worker.js b/test/shared-workers/restricted-to-worker-threads/fixtures/_worker.js index 577a89d9b..a8e664121 100644 --- a/test/shared-workers/restricted-to-worker-threads/fixtures/_worker.js +++ b/test/shared-workers/restricted-to-worker-threads/fixtures/_worker.js @@ -1,3 +1,3 @@ export default async ({negotiateProtocol}) => { - negotiateProtocol(['experimental']).ready(); + negotiateProtocol(['ava4']).ready(); }; diff --git a/test/shared-workers/restricted-to-worker-threads/fixtures/package.json b/test/shared-workers/restricted-to-worker-threads/fixtures/package.json index 82e3ddfc8..bedb411a9 100644 --- a/test/shared-workers/restricted-to-worker-threads/fixtures/package.json +++ b/test/shared-workers/restricted-to-worker-threads/fixtures/package.json @@ -1,8 +1,3 @@ { - "type": "module", - "ava": { - "nonSemVerExperiments": { - "sharedWorkers": true - } - } + "type": "module" } diff --git a/test/shared-workers/restricted-to-worker-threads/fixtures/test.js b/test/shared-workers/restricted-to-worker-threads/fixtures/test.js index 08ef6c44c..09b7617fb 100644 --- a/test/shared-workers/restricted-to-worker-threads/fixtures/test.js +++ b/test/shared-workers/restricted-to-worker-threads/fixtures/test.js @@ -3,7 +3,7 @@ import * as plugin from 'ava/plugin'; plugin.registerSharedWorker({ filename: new URL('_worker.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); test('registering', t => { diff --git a/test/shared-workers/unsupported-protocol/fixtures/in-shared-worker.js b/test/shared-workers/unsupported-protocol/fixtures/in-shared-worker.js index f53681755..79d137bf4 100644 --- a/test/shared-workers/unsupported-protocol/fixtures/in-shared-worker.js +++ b/test/shared-workers/unsupported-protocol/fixtures/in-shared-worker.js @@ -3,7 +3,7 @@ import * as plugin from 'ava/plugin'; plugin.registerSharedWorker({ filename: new URL('_worker.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); test('shared worker should cause tests to fail', t => { diff --git a/test/shared-workers/unsupported-protocol/fixtures/package.json b/test/shared-workers/unsupported-protocol/fixtures/package.json index 058b5540c..82d1f8494 100644 --- a/test/shared-workers/unsupported-protocol/fixtures/package.json +++ b/test/shared-workers/unsupported-protocol/fixtures/package.json @@ -3,9 +3,6 @@ "ava": { "files": [ "*" - ], - "nonSemVerExperiments": { - "sharedWorkers": true - } + ] } } diff --git a/test/shared-workers/worker-execution-crash/fixtures/_plugin.js b/test/shared-workers/worker-execution-crash/fixtures/_plugin.js index 9f630a4d7..1f8a25be1 100644 --- a/test/shared-workers/worker-execution-crash/fixtures/_plugin.js +++ b/test/shared-workers/worker-execution-crash/fixtures/_plugin.js @@ -2,5 +2,5 @@ import * as plugin from 'ava/plugin'; export default plugin.registerSharedWorker({ filename: new URL('_worker.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); diff --git a/test/shared-workers/worker-execution-crash/fixtures/_worker.js b/test/shared-workers/worker-execution-crash/fixtures/_worker.js index a64883c4a..7ef8d21f8 100644 --- a/test/shared-workers/worker-execution-crash/fixtures/_worker.js +++ b/test/shared-workers/worker-execution-crash/fixtures/_worker.js @@ -1,5 +1,5 @@ export default async ({negotiateProtocol}) => { - const protocol = negotiateProtocol(['experimental']); + const protocol = negotiateProtocol(['ava4']); protocol.ready(); crash(protocol.subscribe()); diff --git a/test/shared-workers/worker-execution-crash/fixtures/package.json b/test/shared-workers/worker-execution-crash/fixtures/package.json index 82e3ddfc8..bedb411a9 100644 --- a/test/shared-workers/worker-execution-crash/fixtures/package.json +++ b/test/shared-workers/worker-execution-crash/fixtures/package.json @@ -1,8 +1,3 @@ { - "type": "module", - "ava": { - "nonSemVerExperiments": { - "sharedWorkers": true - } - } + "type": "module" } diff --git a/test/shared-workers/worker-protocol/fixtures/_plugin.js b/test/shared-workers/worker-protocol/fixtures/_plugin.js index 9f630a4d7..1f8a25be1 100644 --- a/test/shared-workers/worker-protocol/fixtures/_plugin.js +++ b/test/shared-workers/worker-protocol/fixtures/_plugin.js @@ -2,5 +2,5 @@ import * as plugin from 'ava/plugin'; export default plugin.registerSharedWorker({ filename: new URL('_worker.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); diff --git a/test/shared-workers/worker-protocol/fixtures/_worker.js b/test/shared-workers/worker-protocol/fixtures/_worker.js index cdfbf2bad..0fb66c93e 100644 --- a/test/shared-workers/worker-protocol/fixtures/_worker.js +++ b/test/shared-workers/worker-protocol/fixtures/_worker.js @@ -1,5 +1,5 @@ export default async ({negotiateProtocol}) => { - const protocol = negotiateProtocol(['experimental']); + const protocol = negotiateProtocol(['ava4']); // When we're ready to receive workers or messages. protocol.ready(); diff --git a/test/shared-workers/worker-protocol/fixtures/package.json b/test/shared-workers/worker-protocol/fixtures/package.json index 82e3ddfc8..bedb411a9 100644 --- a/test/shared-workers/worker-protocol/fixtures/package.json +++ b/test/shared-workers/worker-protocol/fixtures/package.json @@ -1,8 +1,3 @@ { - "type": "module", - "ava": { - "nonSemVerExperiments": { - "sharedWorkers": true - } - } + "type": "module" } diff --git a/test/shared-workers/worker-startup-crashes/fixtures/factory-function.js b/test/shared-workers/worker-startup-crashes/fixtures/factory-function.js index 44c39a5f2..15384e193 100644 --- a/test/shared-workers/worker-startup-crashes/fixtures/factory-function.js +++ b/test/shared-workers/worker-startup-crashes/fixtures/factory-function.js @@ -3,7 +3,7 @@ import * as plugin from 'ava/plugin'; plugin.registerSharedWorker({ filename: new URL('_factory-function.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); test('shared worker should cause tests to fail', t => { diff --git a/test/shared-workers/worker-startup-crashes/fixtures/module.js b/test/shared-workers/worker-startup-crashes/fixtures/module.js index 4c717662a..cc4ef8158 100644 --- a/test/shared-workers/worker-startup-crashes/fixtures/module.js +++ b/test/shared-workers/worker-startup-crashes/fixtures/module.js @@ -3,7 +3,7 @@ import * as plugin from 'ava/plugin'; plugin.registerSharedWorker({ filename: new URL('_module.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); test('shared worker should cause tests to fail', t => { diff --git a/test/shared-workers/worker-startup-crashes/fixtures/no-factory-function.js b/test/shared-workers/worker-startup-crashes/fixtures/no-factory-function.js index 6a6fa3b43..cd3414c7a 100644 --- a/test/shared-workers/worker-startup-crashes/fixtures/no-factory-function.js +++ b/test/shared-workers/worker-startup-crashes/fixtures/no-factory-function.js @@ -3,7 +3,7 @@ import * as plugin from 'ava/plugin'; plugin.registerSharedWorker({ filename: new URL('_no-factory-function.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); test('shared worker should cause tests to fail', t => { diff --git a/test/shared-workers/worker-startup-crashes/fixtures/package.json b/test/shared-workers/worker-startup-crashes/fixtures/package.json index 058b5540c..82d1f8494 100644 --- a/test/shared-workers/worker-startup-crashes/fixtures/package.json +++ b/test/shared-workers/worker-startup-crashes/fixtures/package.json @@ -3,9 +3,6 @@ "ava": { "files": [ "*" - ], - "nonSemVerExperiments": { - "sharedWorkers": true - } + ] } } diff --git a/test/shared-workers/workers-are-loaded-once/fixtures/_plugin.js b/test/shared-workers/workers-are-loaded-once/fixtures/_plugin.js index 4181a0403..4c224ff41 100644 --- a/test/shared-workers/workers-are-loaded-once/fixtures/_plugin.js +++ b/test/shared-workers/workers-are-loaded-once/fixtures/_plugin.js @@ -2,7 +2,7 @@ import * as plugin from 'ava/plugin'; const worker = plugin.registerSharedWorker({ filename: new URL('_worker.js', import.meta.url), - supportedProtocols: ['experimental'], + supportedProtocols: ['ava4'], }); const messages = worker.subscribe(); diff --git a/test/shared-workers/workers-are-loaded-once/fixtures/_worker.js b/test/shared-workers/workers-are-loaded-once/fixtures/_worker.js index 444ff0a59..dcd0dde42 100644 --- a/test/shared-workers/workers-are-loaded-once/fixtures/_worker.js +++ b/test/shared-workers/workers-are-loaded-once/fixtures/_worker.js @@ -1,7 +1,7 @@ import crypto from 'node:crypto'; export default async ({negotiateProtocol}) => { - const protocol = negotiateProtocol(['experimental']).ready(); + const protocol = negotiateProtocol(['ava4']).ready(); const random = crypto.randomBytes(16).toString('hex'); for await (const testWorker of protocol.testWorkers()) { diff --git a/test/shared-workers/workers-are-loaded-once/fixtures/package.json b/test/shared-workers/workers-are-loaded-once/fixtures/package.json index 058b5540c..82d1f8494 100644 --- a/test/shared-workers/workers-are-loaded-once/fixtures/package.json +++ b/test/shared-workers/workers-are-loaded-once/fixtures/package.json @@ -3,9 +3,6 @@ "ava": { "files": [ "*" - ], - "nonSemVerExperiments": { - "sharedWorkers": true - } + ] } }