I want to test my class with jest. This class is importing ajv.js 6.12.2 and the test fails on that. So what i basicly did is:
- Add
export default Ajv
statement to the end of the ajv.js
- Import ajv.js with
import Ajv from './lib/ajv.js'
- Add
"transform": {"^.+\.jsx?$": "babel-jest"}
to package.json
- Created babel.json and insert
{ "presets": ["@babel/preset-env"], "plugins": ["@babel/plugin-proposal-class-properties"] }
When I run the test with npm test
I get the following error:
ReferenceError: Ajv is not defined
> 4 | export default Ajv;`
When I run the script in browser Ajv could be used normally.
Can anybody give me a hint what to do?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…