chai-jest-snapshot
chai-jest-snapshot copied to clipboard
Issues with Mocha + Webpack
I tried both Mocha configuration and framework-agnostic (manual) ones. Doesn't seem to work, as __dirname points to '/' which is not possible to write to (permission).
Any idea how to get it working with Mocha and Webpack? By the way, when I used the recommended way to configure it for Mocha, I got complaints that test name, snapshot name were not set. Apparently the before() beforeEach() were not run, however they were correctly configured as per suggested way.
You should be able to use babel-plugin-transform-dirname-filename to get __dirname
to work. However, if your tests are running in the browser, they won't be able to write to the disk unless fs
's synchronous methods work (which isn't true in Chrome or Firefox, but is true in Electron or nw.js). If you are bundling your tests with webpack but running them in node, though, then you should be fine.
Ok thanks I will give it a bash. In the meantime I resorted to including the snapshots in the tests themselves and comparing to wrapper.html() which is quite readable.