Using jest for testing
vla9isla8 opened this issue · 1 comments
vla9isla8 commented
How can i config prugin for testing using Jest ?
My config (craco.config.js):
const CracoLessPlugin = require("craco-less");
module.exports = {
plugins: [
{
plugin: CracoCesiumPlugin()
}, {
plugin: CracoLessPlugin
}
]
};
Output:
$ craco test
FAIL src/tests/store/init.test.ts
● Test suite failed to run
:2
}(requirejsVars.require, requirejsVars.requirejs, requirejsVars.define));
^
ReferenceError: requirejsVars is not defined
1 | import {Model} from "./Layer";
> 2 | import {Cartesian3, Cartographic, ConstantPositionProperty, JulianDate, PositionProperty, Quaternion} from "cesium";
| ^
3 | import {baseUrl} from "../utils/config";
4 |
5 | class Trackable {
at exec (node_modules/requirejs/bin/r.js:62:23)
at setBaseUrl (node_modules/requirejs/bin/r.js:30248:13)
at node_modules/requirejs/bin/r.js:30338:9
at Object.<anonymous> (node_modules/requirejs/bin/r.js:30427:2)
at Object.<anonymous> (node_modules/cesium/index.js:13:17)
at Object.<anonymous> (src/entities/Trackable.ts:2:1)
rot1024 commented
Unfortunately, if you want to test Cesium in Jest, you have to create mocks for Cesium manually, because Cesium depends on web worker, WebGL, AMD (RequireJS) and so on...
See also: https://github.com/darwin-education/resium/tree/master/__mocks__/cesium