Have some code in a plain JavaScript component that uses async/await. Test works fine when running Jest locally, but when running "bit test" on the code as a component am getting a "ReferenceError: regeneratorRuntime is not defined" error message.
Code:
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function work() {
await timeout(5000);
return true;
}
export default work;
Test:
import work from './index';
describe('foo', () => {
it('should work', async () => {
const result = await work();
expect(result).toEqual(true);
});
});
Adding import 'regenerator-runtime/runtime' to the code makes the test work, but this have to be a requirement just to make the bit tests work
Expected Behaviour
Code using async/await should compile correctly and the appropriate plugins/imports included in the compiler/tester to recognise the regeneratorRuntime function
Specifications
Compiler: bit.envs/compilers/babel@7.0.4
Tester: bit.envs/testers/jest@22.4.3
Bit version: 14.7.2
Have some code in a plain JavaScript component that uses async/await. Test works fine when running Jest locally, but when running "bit test" on the code as a component am getting a "ReferenceError: regeneratorRuntime is not defined" error message.
Code:
Test:
Adding
import 'regenerator-runtime/runtime'
to the code makes the test work, but this have to be a requirement just to make the bit tests workExpected Behaviour
Code using async/await should compile correctly and the appropriate plugins/imports included in the compiler/tester to recognise the regeneratorRuntime function
Specifications
Compiler: bit.envs/compilers/babel@7.0.4 Tester: bit.envs/testers/jest@22.4.3 Bit version: 14.7.2