Open 01binary opened 7 years ago
I found the Nectarine project and used as example 🥇
"babel": {
"presets": [ "env" ],
"plugins": [
[ "transform-react-jsx", { "pragma": "h" } ],
"transform-decorators-legacy"
]
},
Thanks!
^ awesome! We're actually looking at shipping a Jest-based testing setup with preact-cli, and it would support both preact-jsx-chai
and preact-render-spy
.
I may have a better config now, I will post a link to sample project and my config in this thread
Here's my project, it's pre-CSS so the page doesn't look good yet, but it has Jest tests and preact-render-spy. It also uses Recompose, so it's got a fixture that helps test HOCs generated by that library.
https://github.com/01binary/ultravest-assistant
I think I found a good balance of testing state & mutators separately from state transforms and separately from UI:
preact-render-spy
:
identity-obj-proxy
to resolve imported CSS classes during tests, because that just gives the class name instead of undefined or the hashed CSS name.
Is there an article on setting this up with preact-cli created project? I have no doubt you are very busy so I will keep hacking, but if you know what's happening please let me know.
$ mocha --recursive --require babel-polyfill --compilers js:babel-register
Gets me:
I have some other tests that don't use JSX and work. I ended up putting babel "env" preset into my
package.json
because I go to extreme lengths to keep my package root clean, but doing the same with.babelrc
didn't make any difference. My package is customized from whatpreact-cli
did, in an attempt to get tests to work:I am confused because error message indicates it's getting transpiled through babylon but it's still unhappy.