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

test: correct execution of test and dev scripts on Windows machines #4926

Merged
merged 4 commits into from May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/types/tools/copy-ast-spec.ts
Expand Up @@ -15,6 +15,7 @@ async function execAsync(
return new Promise((resolve, reject) => {
const child = childProcess.spawn(command, args, {
...options,
shell: process.platform === 'win32',
stdio: 'inherit',
});

Expand Down
Expand Up @@ -92,7 +92,10 @@ class FixturesTester {
return this.fixtures
.map(fixture =>
glob
.sync(`${fixture.directory}/${fixture.pattern}`, {})
.sync(fixture.pattern, {
cwd: fixture.directory,
absolute: true,
})
.map(filename => ({
filename,
ignoreSourceType: fixture.ignoreSourceType,
Expand Down Expand Up @@ -346,7 +349,6 @@ tester.addFixturePatternConfig('typescript/basics', {
/**
* Not yet supported in Babel
* Directive field is not added to module and namespace
* @see https://github.com/babel/babel/issues/9228
*/
'directive-in-module',
'directive-in-namespace',
Expand Down
28 changes: 15 additions & 13 deletions packages/typescript-estree/tests/ast-fixtures.test.ts
Expand Up @@ -15,7 +15,7 @@ addSerializer(serializer);
// prettier-ignore
const ONLY = [].join(path.sep);

const FIXTURES_DIR = path.resolve(
const fixturesDir = path.resolve(
__dirname,
'..',
'..',
Expand All @@ -25,15 +25,15 @@ const FIXTURES_DIR = path.resolve(
'shared-fixtures',
'fixtures',
);
const SNAPSHOTS_DIR = path.resolve(__dirname, 'snapshots');
const snapshotsDir = path.resolve(__dirname, 'snapshots');

const fixtures = glob
.sync(`${FIXTURES_DIR}/**/*.src.{js,ts,jsx,tsx}`)
.sync(`**/*.src.{js,ts,jsx,tsx}`, { cwd: fixturesDir, absolute: true })
.map(absolute => {
const relative = path.relative(FIXTURES_DIR, absolute);
const relative = path.relative(fixturesDir, absolute);
const { name, dir, ext } = path.parse(relative);
const segments = dir.split(path.sep);
const snapshotPath = path.join(SNAPSHOTS_DIR, dir);
const snapshotPath = path.join(snapshotsDir, dir);
return {
absolute,
isJsx: isJSXFileType(ext),
Expand Down Expand Up @@ -97,14 +97,16 @@ fixtures.forEach(f => nestDescribe(f));

if (ONLY === '') {
// ensure that the snapshots are cleaned up, because jest-specific-snapshot won't do this check
const snapshots = glob.sync(`${SNAPSHOTS_DIR}/**/*.shot`).map(absolute => {
const relative = path.relative(SNAPSHOTS_DIR, absolute);
const { name, dir } = path.parse(relative);
return {
relative,
fixturePath: path.join(FIXTURES_DIR, dir, name),
};
});
const snapshots = glob
.sync(`**/*.shot`, { cwd: snapshotsDir, absolute: true })
.map(absolute => {
const relative = path.relative(snapshotsDir, absolute);
const { name, dir } = path.parse(relative);
return {
relative,
fixturePath: path.join(fixturesDir, dir, name),
};
});

describe('ast snapshots should have an associated test', () => {
for (const snap of snapshots) {
Expand Down