Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link to Update Snapshot is not working #2749

Closed
martinduo opened this issue Jul 8, 2021 · 4 comments
Closed

Link to Update Snapshot is not working #2749

martinduo opened this issue Jul 8, 2021 · 4 comments

Comments

@martinduo
Copy link

Issue description or question

Wallaby's link to Update Snapshot is not working correctly. Here's the scenario:

I have many Jest test suites. I spent a bit of time yesterday to resolve snapshot errors that were expected due to my code changes. All the snapshot errors plus a few other errors were in a single Jest test suite. I was running only this single test suite, and I clicked your X errors link to use your command window (terminology ?) to see side-by-side diff's and to click Update Screenshot. This all worked. The single test suite ran with all tests passing, the screen shot errors and the few other errors were gone.

Then I switched my launch.json action to the one that runs all the Jest test. And here I still get the Screenshot errors and the others in that one test suite. Again I use Wallaby to inspect the diff's and to update the screen shots. But when I again run all the Jest tests, the terminal output still shows the same errors in that one suite. And when I click your X tab to get the command window, you do not show me any screeshot errors, only the few other ones. Very strange.

Going back to run the single Jest test suite, it runs with all passing. But running the all Jest test suites continues to show the screenshot errors and the others that were cleared in the individual test run. So it appears that the Wallaby link to update the screenshots didn't work when I was using the launch.json to run all tests. But apparently Wallaby think they were updated and doesn't show them, yet the other errors that were cleared in the individual run when the screenshot were actually updated still are seen by Wallaby. So the screenshots were not updated, even though Wallaby thinks they are.

Wallaby diagnostics report

module.exports = () => {
return {
files: ['src//*.js'],
tests: ['src/
/*.spec.js'],
env: {
type: 'node',
},
}
}

@smcenlly
Copy link
Member

smcenlly commented Jul 8, 2021

You mention screenshot a few times above, I assume that this is just a typo and that you mean snapshot?

In the place of Wallaby diagnostics report section (above), it looks like you have provided a manual Wallaby configuration file. If you are attempting to run jest tests with this configuration then Wallaby is going to be using jasmine for the testing framework and snapshots will not work for you.

Could you please provide us with your Wallaby Diagnostics report? To share the report:

  • start Wallaby in your project;
  • wait until it reports some results (finishes running tests);
  • run Copy Diagnostics Report command:
    • in VS Code, Atom, or Sublime editor execute Wallaby Copy Diagnostics Report command from your editor command palette;
    • in JetBrains IDEs or VS use Wallaby Help | Wallaby.js | Copy Diagnostics Report menu item;
  • paste generated report from your clipboard below (feel free to review and edit the report if required).

Also, are you able to share the code that has this problem so that we can see it for ourselves (perhaps privately via email if privacy is a concern)? We're a little confused as to the exact steps that you're taking to understand the problem so it might help if we can play around and see for ourselves.

@martinduo
Copy link
Author

martinduo commented Jul 9, 2021

Yes I did mean snapshot. And I did the exact steps you list to get the data that I pasted in the Wallaby diagnostics report section. If my configuration is using jasmine, please tell me how to change the configuration to use Jest. I'm sure I installed it following the directions. I'm using VS Code on Windows 10 and the project is a CRA generated framework. Doesn't installing the Wallaby extension handle it all? But just thinking about what I did to install Wallaby gives me an idea about what may be the problem. My current project is a union of two difference development projects #1 and #2. #1 was done first and is a CRA app with all the UI for a financial planning app. This was done before I even knew about Wallaby. #2 is the calculation engine that creates the financial data for the UI. #2 was developed separately from converted VB.Net code and is like 60,000 lines of code. #2 was developed using node with babel so I could code it with es6 imports. This is where I learned about Wallaby and it was installed there on VS Code. Just recently I merged these two projects together and the Wallaby extension was carried over. Would that have configure Wallaby incorrectly for the present merged project? If so, how do I configure it correctly? Uninstall and reinstall?

Edited: P.S. When I run all the Jest tests, I use the .vscode launch.json file using this configuration , which was what I used when working on the calculation engine in #2 project. This is to enable debugging support.

{ "name": "Run all Jest", "type": "node", "request": "launch", "program": "${workspaceFolder}/node_modules/.bin/jest", "args": ["--runInBand"], "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", "windows": { "program": "${workspaceFolder}/node_modules/jest/bin/jest" } },

@smcenlly
Copy link
Member

smcenlly commented Jul 9, 2021

Just recently I merged these two projects together and the Wallaby extension was carried over. Would that have configure Wallaby incorrectly for the present merged project?

This may well be the cause of your problem. It seems that your Wallaby diagnostic report didn't copy properly as the format you provided is not what is provided by the command. I am guessing that you have a wallaby.js configuration file and are not using automatic configuration? I am also guessing that your CRA tests are running using jest but your calculation engine is using something different (e.g. jasmine)?

Wallaby does not currently support running multiple different frameworks at the same time (i.e. all of your tests must be jest, or all must be jasmine). If everything is not using the same framework, you can create different configurations to run them separately (e.g. wallaby.jest.js and wallaby.jasmine.js).

If so, how do I configure it correctly? Uninstall and reinstall?

There is no need to reinstall. Without knowing your project structure and how you're running the calculator tests, we can't provide you with exact steps. Assuming you're running the calculator and CRA tests in different frameworks, the steps below should help.

  1. Create a wallaby.jest.js configuration file with the following code:

wallaby.jest.js

module.exports = () => ({
   autoDetect: true
});
  1. Create a wallaby.jasmine.js configuration file with the following code:

wallaby.jasmine.js

module.exports = () => {
  return {
    files: [
      "src//*.js"
    ],
    tests: [
      // TODO: update to exclude any tests that are run using jest
      "src//*.spec.js"
    ],
    env: {
      type: "node",
    },
  };
};
  1. Update the file created in step 2 to exclude any tests that are run by jest.

If all of your tests are running with jest, then you do not need to complete steps 2 and 3. You may also switch from running with a configuration file to using Wallaby's automatic configuration. If you do this, you may delete all configuration files.

@martinduo
Copy link
Author

I'm using Jest for all my tests, so I added "wallaby": { "autoDetect": true }, to my package.json. Now when I run Wallaby diagnostics report, I get the whole thing. Thanks for you help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants