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
4. Add jest custom transformer file `workerize-jest.js` in root dir:
135
-
```ts
144
+
145
+
Finally, create the custom Jest transformer referenced above as a file `workerize-jest.js` in your project's root directory (where the package.json is):
async function asyncify() { return this.apply(null, arguments); }
152
+
module.exports = function() {
153
+
const w = require(${JSON.stringify(filename.replace(/^.+!/, ''))});
154
+
const m = {};
155
+
for (let i in w) m[i] = asyncify.bind(w[i]);
156
+
return m;
157
+
};
158
+
`;
159
+
}
140
160
};
141
161
```
142
162
143
-
Now your tests and any modules they import can use `workerize-loader!` prefixes.
163
+
Now your tests and any modules they import can use `workerize-loader!` prefixes, and the imports will be turned into async functions just like they are in Workerize.
0 commit comments