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: allow to execute tests on windows #6488

Merged
merged 3 commits into from Feb 18, 2023
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
14 changes: 11 additions & 3 deletions packages/ast-spec/tests/fixtures.test.ts
Expand Up @@ -38,10 +38,18 @@ const fixturesWithErrorDifferences = {
} as const;

const VALID_FIXTURES: readonly string[] = glob.sync(
`${SRC_DIR}/**/fixtures/*/fixture.{ts,tsx}`,
`**/fixtures/*/fixture.{ts,tsx}`,
{
cwd: SRC_DIR,
absolute: true,
},
);
const ERROR_FIXTURES: readonly string[] = glob.sync(
`${SRC_DIR}/**/fixtures/_error_/*/fixture.{ts,tsx}`,
`**/fixtures/_error_/*/fixture.{ts,tsx}`,
{
cwd: SRC_DIR,
absolute: true,
},
);

const FIXTURES: readonly Fixture[] = [...VALID_FIXTURES, ...ERROR_FIXTURES].map(
Expand All @@ -66,7 +74,7 @@ const FIXTURES: readonly Fixture[] = [...VALID_FIXTURES, ...ERROR_FIXTURES].map(
isError: absolute.includes('/_error_/'),
isJSX: ext.endsWith('x'),
name,
relative: path.relative(SRC_DIR, absolute),
relative: path.relative(SRC_DIR, absolute).replace(/\\/g, '/'),
segments,
snapshotFiles: {
success: {
Expand Down

This file was deleted.

26 changes: 18 additions & 8 deletions packages/typescript-estree/tests/lib/getProjectConfigFiles.test.ts
@@ -1,3 +1,5 @@
import path from 'path';

import { ExpiringCache } from '../../src/parseSettings/ExpiringCache';
import { getProjectConfigFiles } from '../../src/parseSettings/getProjectConfigFiles';

Expand Down Expand Up @@ -51,12 +53,16 @@ describe('getProjectConfigFiles', () => {
getProjectConfigFiles(parseSettings, true);
const actual = getProjectConfigFiles(parseSettings, true);

expect(actual).toEqual(['repos/repo/packages/package/tsconfig.json']);
expect(actual).toEqual([
path.normalize('repos/repo/packages/package/tsconfig.json'),
]);
expect(mockExistsSync).toHaveBeenCalledTimes(1);
});

it('returns a nearby parent tsconfig.json when it was previously cached by a different directory search', () => {
mockExistsSync.mockImplementation(input => input === 'a/tsconfig.json');
mockExistsSync.mockImplementation(
input => input === path.normalize('a/tsconfig.json'),
);

const tsconfigMatchCache = new ExpiringCache<string, string>(1);

Expand All @@ -81,12 +87,14 @@ describe('getProjectConfigFiles', () => {
true,
);

expect(actual).toEqual(['a/tsconfig.json']);
expect(actual).toEqual([path.normalize('a/tsconfig.json')]);
expect(mockExistsSync).toHaveBeenCalledTimes(4);
});

it('returns a distant parent tsconfig.json when it was previously cached by a different directory search', () => {
mockExistsSync.mockImplementation(input => input === 'a/tsconfig.json');
mockExistsSync.mockImplementation(
input => input === path.normalize('a/tsconfig.json'),
);

const tsconfigMatchCache = new ExpiringCache<string, string>(1);

Expand All @@ -111,7 +119,7 @@ describe('getProjectConfigFiles', () => {
true,
);

expect(actual).toEqual(['a/tsconfig.json']);
expect(actual).toEqual([path.normalize('a/tsconfig.json')]);
expect(mockExistsSync).toHaveBeenCalledTimes(6);
});
});
Expand All @@ -122,17 +130,19 @@ describe('getProjectConfigFiles', () => {

const actual = getProjectConfigFiles(parseSettings, true);

expect(actual).toEqual(['repos/repo/packages/package/tsconfig.json']);
expect(actual).toEqual([
path.normalize('repos/repo/packages/package/tsconfig.json'),
]);
});

it('returns a parent tsconfig.json when matched', () => {
mockExistsSync.mockImplementation(
filePath => filePath === 'repos/repo/tsconfig.json',
filePath => filePath === path.normalize('repos/repo/tsconfig.json'),
);

const actual = getProjectConfigFiles(parseSettings, true);

expect(actual).toEqual(['repos/repo/tsconfig.json']);
expect(actual).toEqual([path.normalize('repos/repo/tsconfig.json')]);
});

it('throws when searching hits .', () => {
Expand Down
Expand Up @@ -42,7 +42,7 @@ describe('parseAndGenerateServices', () => {
filePath: join(PROJECT_DIR, 'notIncluded.ts'),
}),
).toThrow(
/project was set to `true` but couldn't find any tsconfig.json relative to '.+\/tests\/fixtures\/projectTrue\/notIncluded.ts' within '.+\/tests\/fixtures\/projectTrue'./,
/project was set to `true` but couldn't find any tsconfig.json relative to '.+[/\\]tests[/\\]fixtures[/\\]projectTrue[/\\]notIncluded.ts' within '.+[/\\]tests[/\\]fixtures[/\\]projectTrue'./,
);
});
});
Expand Down