Closed sunnypp closed 5 years ago
@sunnypp The jest transform module is required to solve this problem, but it does not currently exist. Currently this loader is used exclusively for webpack, but should be used elsewhere, such as jest, rollup, etc. To do this, I have to separate the code that converts the pug to jsx and make it available for use in various loaders. I've started this job from the repository below. https://github.com/bluewings/pug-as-jsx-utils
I will inform you again in the future when the conversion module for the jest is complete.
@sunnypp
I am sorry for being late.
After npm install jest-transform-pug-as-jsx
, add the pug transform setting in jest config.
see: https://github.com/bluewings/pug-as-jsx-loader/commit/79c2c4f40a086af572f2ef685c7ae4179480b54b
Then you can pass npm test
.
PASS src/App.test.js
✓ renders without crashing (22ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 2.462s
Ran all test suites.
Watch Usage: Press w to show more.
PS. I also updated the example for 'cra-rewired'. https://github.com/bluewings/cra-rewired/tree/master/examples/pug-as-jsx-loader You can override the jest setting as shown below. https://github.com/bluewings/cra-rewired/blob/master/examples/pug-as-jsx-loader/config/jest.custom.js
I have projects that runs without problem that uses
pug-as-jsx-loader
.However when running
npm test
, no matter I am usingcra-rewired
or manually ejecting and modifying webpack config, I cannot get the defaultnpm test
passes.Do we have suggested ways to do testing if we use
pug-as-jsx-loader
?P.S. For the
cra-rewired
version, I triedcra-rewired -s react-scripts -m test -c webpack.custom.js
but that seems to be an entrance to a a deeper hole.