- react:16.3.0-alpha.1
- jest: "22.3.0"
- enzyme: 3.3.0
- typescript: 2.7.1
code:
class Foo extends React.PureComponent<undefined,undefined>{
bar:number;
async componentDidMount() {
this.bar = 0;
let echarts = await import('echarts'); // async import
this.bar = 100;
}
}
test:
describe('...', () => {
test('...', async () => {
const wrapper = shallow(<Foo/>);
const instance = await wrapper.instance();
expect(instance.bar).toBe(100);
});
});
Error:
Expected value to be:
100
Received:
0