Require output fixture extension to match sourceType output.
This commit is contained in:
parent
beb99dfda1
commit
7cc00cce0d
@ -67,6 +67,7 @@ export function runSync(
|
|||||||
ast: opts.ast === true ? file.ast : null,
|
ast: opts.ast === true ? file.ast : null,
|
||||||
code: outputCode === undefined ? null : outputCode,
|
code: outputCode === undefined ? null : outputCode,
|
||||||
map: outputMap === undefined ? null : outputMap,
|
map: outputMap === undefined ? null : outputMap,
|
||||||
|
sourceType: file.ast.program.sourceType,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -397,11 +397,28 @@ function run(task) {
|
|||||||
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
|
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
|
||||||
!process.env.CI
|
!process.env.CI
|
||||||
) {
|
) {
|
||||||
console.log(`New test file created: ${expected.loc}`);
|
const expectedFile = expected.loc.replace(
|
||||||
fs.writeFileSync(expected.loc, `${result.code}\n`);
|
/\.m?js$/,
|
||||||
|
result.sourceType === "module" ? ".mjs" : ".js",
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`New test file created: ${expectedFile}`);
|
||||||
|
fs.writeFileSync(expectedFile, `${result.code}\n`);
|
||||||
|
|
||||||
|
if (expected.loc !== expectedFile) {
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(expected.loc);
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
actualCode = result.code.trim();
|
actualCode = result.code.trim();
|
||||||
expect(actualCode).toEqual(expectCode);
|
expect(actualCode).toEqual(expectCode);
|
||||||
|
|
||||||
|
if (actualCode) {
|
||||||
|
expect(expected.loc).toMatch(
|
||||||
|
result.sourceType === "module" ? /\.mjs$/ : /\.js$/,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user