You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/recipes/shared-workers.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,14 +37,14 @@ Plugins communicate with their shared worker using a *protocol*. Protocols are v
37
37
38
38
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.
39
39
40
-
**For AVA 3, substitute `'ava4'` with `'experimental'`.**
40
+
**For AVA 3, substitute `'ava-4'` with `'experimental'`.**
41
41
42
42
```js
43
43
import {registerSharedWorker} from'ava/plugin';
44
44
45
45
constshared=registerSharedWorker({
46
46
filename:path.resolve(__dirname, 'worker.js'),
47
-
supportedProtocols: ['ava4']
47
+
supportedProtocols: ['ava-4']
48
48
});
49
49
```
50
50
@@ -55,7 +55,7 @@ You can supply a `teardown()` function which will be called after all tests have
55
55
```js
56
56
constworker=registerSharedWorker({
57
57
filename:path.resolve(__dirname, 'worker.js'),
58
-
supportedProtocols: ['ava4'],
58
+
supportedProtocols: ['ava-4'],
59
59
teardown () {
60
60
// Perform any clean-up within the test process itself.
61
61
}
@@ -68,7 +68,7 @@ You can also provide some data passed to the shared worker when it is loaded. Of
68
68
constshared=registerSharedWorker({
69
69
filename:path.resolve(__dirname, 'worker.js'),
70
70
initialData: {hello:'world'},
71
-
supportedProtocols: ['ava4']
71
+
supportedProtocols: ['ava-4']
72
72
});
73
73
```
74
74
@@ -84,7 +84,7 @@ The default export must be a factory method. Like when calling `registerSharedWo
84
84
85
85
```js
86
86
exportdefault ({negotiateProtocol}) => {
87
-
constmain=negotiateProtocol(['ava4']);
87
+
constmain=negotiateProtocol(['ava-4']);
88
88
}
89
89
```
90
90
@@ -104,7 +104,7 @@ In the shared worker you can subscribe to messages from test workers:
104
104
105
105
```js
106
106
exportdefaultasync ({negotiateProtocol}) => {
107
-
constmain=negotiateProtocol(['ava4']).ready();
107
+
constmain=negotiateProtocol(['ava-4']).ready();
108
108
109
109
forawait (constmessageofmain.subscribe()) {
110
110
// …
@@ -122,7 +122,7 @@ To illustrate this here's a "game" of Marco Polo:
122
122
123
123
```js
124
124
exportdefault ({negotiateProtocol}) => {
125
-
constmain=negotiateProtocol(['ava4']).ready();
125
+
constmain=negotiateProtocol(['ava-4']).ready();
126
126
127
127
play(main.subscribe());
128
128
};
@@ -143,7 +143,7 @@ You can also broadcast messages to all connected test workers:
143
143
144
144
```js
145
145
exportdefaultasync ({negotiateProtocol}) => {
146
-
constmain=negotiateProtocol(['ava4']).ready();
146
+
constmain=negotiateProtocol(['ava-4']).ready();
147
147
148
148
forawait (constmessageofmain.subscribe()) {
149
149
if (message.data==='Bingo!') {
@@ -163,7 +163,7 @@ Of course you don't need to wait for a message *from* a test worker to access th
163
163
164
164
```js
165
165
exportdefaultasync ({negotiateProtocol}) => {
166
-
constmain=negotiateProtocol(['ava4']).ready();
166
+
constmain=negotiateProtocol(['ava-4']).ready();
167
167
168
168
forawait (consttestWorkerofmain.testWorkers()) {
169
169
main.broadcast(`New test file: ${testWorker.file}`);
@@ -205,7 +205,7 @@ You can register teardown functions to be run when the test worker exits:
205
205
206
206
```js
207
207
exportdefaultasync ({negotiateProtocol}) => {
208
-
constmain=negotiateProtocol(['ava4']).ready();
208
+
constmain=negotiateProtocol(['ava-4']).ready();
209
209
210
210
forawait (consttestWorkerofmain.testWorkers()) {
211
211
testWorker.teardown(() => {
@@ -221,7 +221,7 @@ More interestingly, a wrapped teardown function is returned so that you can call
0 commit comments