-
Notifications
You must be signed in to change notification settings - Fork 17
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
Feature Request: Ability to have snapshots be placed in a __snapshots__ folder when using mocha #27
Comments
You should be able to do it like this: import path from "path";
import chai from "chai";
import chaiJestSnapshot from "chai-jest-snapshot";
chai.use(chaiJestSnapshot);
before(function() {
chaiJestSnapshot.resetSnapshotRegistry();
});
beforeEach(function() {
const { currentTest } = this;
const filename = path.resolve(path.dirname(currentTest.file), "__snapshots__", path.basename(currentTest.file) + ".snap");
chaiJestSnapshot.setFilename(filename);
chaiJestSnapshot.setTestName(currentTest.fullTitle());
}); Depending on your use-case, you might have to also add code in the |
works a treat, thanks! would be good to have this as a config option? |
Maybe if enough people request it, but since you can do it using setFilename and setTestName, I don't think it's strictly necessary. |
Would be nice to have this documented in README. Though, as I would expect this package is of interest for people migrating from Jest to Mocha, it would be nice to have a special config option for that. |
Hi!
This would be quite nice if it's possible. This line looks promising: https://github.com/suchipi/chai-jest-snapshot/blob/master/src/buildConfigState.js#L19 but haven't looked into it much.
The text was updated successfully, but these errors were encountered: