- react:16.3.0-alpha.1
- 开玩笑:“22.3.0”
- 酶:3.3.0
- typescript:2.7.1
代码:
class Foo extends React.PureComponent<undefined,undefined>{
bar:number;
async componentDidMount() {
this.bar = 0;
let echarts = await import('echarts'); // async import
this.bar = 100;
}
}
测试:
describe('...', () => {
test('...', async () => {
const wrapper = shallow(<Foo/>);
const instance = await wrapper.instance();
expect(instance.bar).toBe(100);
});
});
错误:
Expected value to be:
100
Received:
0