提交 27451e69 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: fix toSaveImageSnapshot error

上级 6ce2b6f3
......@@ -71,7 +71,7 @@ function toSaveSnapshot(received, {
let pass = true;
try {
checkSnapshotDir(snapshotDir);
checkSnapshotDir(path.dirname(filePath));
fs.writeFileSync(filePath, received);
writeTestCaseToSnapshotFile(testPath.replace(`${_rootDir}/`, ""), filePath);
} catch (e) {
......@@ -108,7 +108,7 @@ function toSaveImageSnapshot(
SNAPSHOTS_DIR,
});
const _fileName = createFileName({
fileName: customSnapshotIdentifier ? customSnapshotIdentifier() : "",
fileName: customSnapshotIdentifier ? `${customSnapshotIdentifier()}.png` : "",
testPath,
currentTestName,
fileType: "png",
......@@ -118,7 +118,7 @@ function toSaveImageSnapshot(
let pass = true;
try {
checkSnapshotDir(snapshotDir);
checkSnapshotDir(path.dirname(filePath));
fs.writeFileSync(filePath, Buffer.from(received, "base64"));
writeTestCaseToSnapshotFile(testPath.replace(`${_rootDir}/`, ""), filePath);
} catch (e) {
......
......@@ -41,7 +41,7 @@ describe('toSaveSnapshot & toSaveImageSnapshot template', () => {
expect(img1).toSaveImageSnapshot({
customSnapshotsDir: './customDir/__image_snapshots__',
customSnapshotIdentifier() {
return 'test-toSaveImageSnapshot-2-1.png';
return 'test-toSaveImageSnapshot-2-1';
},
})
......@@ -53,7 +53,7 @@ describe('toSaveSnapshot & toSaveImageSnapshot template', () => {
const img3 = await program.screenshot();
expect(img3).toSaveImageSnapshot({
customSnapshotIdentifier() {
return 'test-toSaveImageSnapshot-2-3.png';
return 'test-toSaveImageSnapshot-2-3';
},
})
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册