bahmutov / snap-shot

Jest-like snapshot feature for the rest of us, works magically by finding the right caller function
169 stars 3 forks source link

JSX in source file crashes `find-test-caller` #69

Open fatso83 opened 7 years ago

fatso83 commented 7 years ago

I have tried following the steps outlined in various guides here, the main difference being that I am using Mocha and JSDOM instead of Jest. When running my tests I get the error Problem finding caller, which I debugged and traced to the function findTestCaller in the find-test-caller module.

After enabling debug output I got

  find-test-caller problem finding without transpiling /home/developer/dev/myproj/tests/mocha/client/unit/components/UserAccountInfo.test.js 87 +0ms
  find-test-caller Unexpected token (79:6) +1ms
  find-test-caller should transpile and search +1ms

Basically it advises me to transpile before searching, but I haven't seen any hints on doing this in the howtos I have seen. Any pointers? Of course, to run that test at all I already have transpiled the test inside Mocha (using babel-register).

This is the test code

  it('should render without regressions', function () {
    const renderer = ReactRenderer.create(
      <MuiThemeProvider muiTheme={muiTheme}>
        <UserAccountInfo {...createDefaultProps()}/>
      </MuiThemeProvider>
    );
    const json = renderer.toJSON();
    snapshot(json);
  });