Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/target.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,36 @@ export default class Target {
}
}

async toMatchSnapshot(image, callback) {
async toMatchSnapshot(image, callback, settings) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could move all these sanitizations to a separate function like sanitiseToMatchSnapshotArg()?!

let resultCallback;
if (image && !isFunc(image)) {
let providedName = false;
if (image && !isFunc(image) && !image.name) {
this.image = image;
} else if (isFunc(image)) {
resultCallback = image;
} else if (image && image.name) {
providedName = image.name;
}
if (callback && isFunc(callback)) {
resultCallback = callback;
} else if (callback && callback.name) {
providedName = callback.name;
}
if (settings && settings.name) {
providedName = settings.name;
}
if (this.testConfig.isJest && !this.testConfig.testNameProvided) {
this.testConfig.testName = this.testId
? `${this.testStats.currentTestName} ${this.testId}`
: this.testStats.currentTestName;
} else {
this.testConfig.testName = this.testId
? `${this.testConfig.testName} ${this.testId}`
: this.testConfig.testName;
if (providedName) {
this.testConfig.testName = providedName;
} else {
this.testConfig.testName = this.testId
? `${this.testConfig.testName} ${this.testId}`
: this.testConfig.testName;
}
}
this.testId += 1;
const result = await this._evaluateResult();
Expand Down