Skip to content

chore: cleanup test-utils naming/locations #8341

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

Merged
merged 2 commits into from
Feb 2, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/parser/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
...require('../../jest.config.base.js'),
testRegex: './tests/lib/.+\\.ts$',
testRegex: './tests/lib/.+\\.test\\.ts$',
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
createSnapshotTestBlock,
formatSnapshotName,
testServices,
} from '../tools/test-utils';
} from '../test-utils/test-utils';

//------------------------------------------------------------------------------
// Setup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ParserOptions } from '@typescript-eslint/types';

import { parseForESLint } from '../../src/parser';
import { serializer } from '../tools/ts-error-serializer';
import { serializer } from '../test-utils/ts-error-serializer';

//------------------------------------------------------------------------------
// Tests
Expand Down
2 changes: 1 addition & 1 deletion packages/scope-manager/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ module.exports = {
...baseConfig,
setupFilesAfterEnv: [
...baseConfig.setupFilesAfterEnv,
'./tests/util/serializers/index.ts',
'./tests/test-utils/serializers/index.ts',
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('arguments', () => {
it('arguments are correctly materialized', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('catch', () => {
it('creates scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TSESTree } from '@typescript-eslint/types';

import { analyze } from '../../src/analyze';
import { parse } from '../util';
import { parse } from '../test-utils';

describe('childVisitorKeys option', () => {
it('should not visit to properties which are not given.', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
expectToBeGlobalScope,
expectToBeIdentifier,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('Class fields', () => {
it('class C { f = g }', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 arrow function expression', () => {
it('materialize scope for arrow function expression', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 block scope', () => {
it('let is materialized in ES6 block scope#1', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 catch', () => {
it('takes binding pattern', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 class', () => {
it('declaration name creates class scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getRealVariables, parseAndAnalyze } from '../util';
import { getRealVariables, parseAndAnalyze } from '../test-utils';

function forEach<T extends string>(
obj: Record<T, string>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
expectToBeParameterDefinition,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 destructuring assignments', () => {
it('Pattern in var in ForInStatement', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
expectToBeVariableDefinition,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('export declaration', () => {
// http://people.mozilla.org/~jorendorff/es6-draft.html#sec-static-and-runtme-semantics-module-records
Expand Down
4 changes: 2 additions & 2 deletions packages/scope-manager/tests/eslint-scope/es6-import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
expectToBeModuleScope,
expectToBeVariableDefinition,
getRealVariables,
} from '../util';
import { parseAndAnalyze } from '../util/parse';
} from '../test-utils';
import { parseAndAnalyze } from '../test-utils/parse';

describe('import declaration', () => {
// http://people.mozilla.org/~jorendorff/es6-draft.html#sec-static-and-runtme-semantics-module-records
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
expectToBeVariableDefinition,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 iteration scope', () => {
it('let materialize iteration scope for ForInStatement#1', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
expectToBeFunctionScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 new.target', () => {
it('should not make references of new.target', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 object', () => {
it('method definition', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
expectToBeParameterDefinition,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 rest arguments', () => {
it('materialize rest argument in scope', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 super', () => {
it('is not handled as reference', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
expectToBeSwitchScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 switch', () => {
it('materialize scope', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('ES6 template literal', () => {
it('refer variables', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('function name', () => {
it('should create its special scope', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types';
import { simpleTraverse } from '@typescript-eslint/typescript-estree';

import { analyze } from '../../src/analyze';
import { parse } from '../util/parse';
import { parse } from '../test-utils/parse';

describe('ScopeManager.prototype.getDeclaredVariables', () => {
function verify(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('global increment', () => {
it('becomes read/write', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
expectToBeImportBindingDefinition,
expectToBeModuleScope,
getRealVariables,
} from '../util';
import { parseAndAnalyze } from '../util/parse';
} from '../test-utils';
import { parseAndAnalyze } from '../test-utils/parse';

describe('gloablReturn option', () => {
it('creates a function scope following the global scope immediately', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('implicit global reference', () => {
it('assignments global scope', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
expectToBeGlobalScope,
expectToBeModuleScope,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('impliedStrict option', () => {
it('ensures all user scopes are strict', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/scope-manager/tests/eslint-scope/label.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('label', () => {
it('should not create variables', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getRealVariables, parseAndAnalyze } from '../util';
import { getRealVariables, parseAndAnalyze } from '../test-utils';

describe('References:', () => {
describe('When there is a `let` declaration on global,', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('typescript', () => {
describe('multiple call signatures', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
expectToBeWithScope,
getRealVariables,
parseAndAnalyze,
} from '../util';
} from '../test-utils';

describe('with', () => {
it('creates scope', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/scope-manager/tests/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import glob = require('glob');
import makeDir from 'make-dir';
import path from 'path';

import type { AnalyzeOptions } from './util';
import { parseAndAnalyze } from './util';
import type { AnalyzeOptions } from './test-utils';
import { parseAndAnalyze } from './test-utils';

// Assign a segment set to this variable to limit the test to only this segment
// This is super helpful if you need to debug why a specific fixture isn't producing the correct output
Expand Down
2 changes: 1 addition & 1 deletion packages/scope-manager/tests/lib.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ImplicitLibVariable } from '../src';
import { parseAndAnalyze } from './util';
import { parseAndAnalyze } from './test-utils';

describe('implicit lib definitions', () => {
it('should define no implicit variables if provided an empty array', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/scope-manager/tests/types/reference-type.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AST_NODE_TYPES } from '@typescript-eslint/types';

import { getSpecificNode, parseAndAnalyze } from '../util';
import { getSpecificNode, parseAndAnalyze } from '../test-utils';

describe('referencing a type - positive', () => {
it('records a reference when a type is referenced from a type', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AST_NODE_TYPES } from '@typescript-eslint/types';

import { getSpecificNode, parseAndAnalyze } from '../util';
import { getSpecificNode, parseAndAnalyze } from '../test-utils';

describe('variable definition', () => {
it('defines a variable for a type declaration', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-estree/tests/lib/semanticInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import type { ParseAndGenerateServicesResult } from '../../src/parser';
import { parseAndGenerateServices } from '../../src/parser';
import type { TSESTreeOptions } from '../../src/parser-options';
import type { TSESTree } from '../../src/ts-estree';
import { expectToHaveParserServices } from '../test-utils/expectToHaveParserServices';
import {
createSnapshotTestBlock,
formatSnapshotName,
parseCodeAndGenerateServices,
} from '../../tools/test-utils';
import { expectToHaveParserServices } from './test-utils/expectToHaveParserServices';
} from '../test-utils/test-utils';

const FIXTURES_DIR = './tests/fixtures/semanticInfo';
const testFiles = glob.sync(`**/*.src.ts`, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
ParserServices,
ParserServicesWithTypeInformation,
} from '../../../src';
} from '../../src';

export function expectToHaveParserServices(
services: ParserServices | null | undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type {
ParseAndGenerateServicesResult,
TSESTree,
TSESTreeOptions,
} from '../src';
import { parse as parserParse, parseAndGenerateServices } from '../src';
} from '../../src';
import { parse as parserParse, parseAndGenerateServices } from '../../src';

export function parseCodeAndGenerateServices(
code: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Plugin } from 'pretty-format';

import { TSError } from '../src/node-utils';
import { TSError } from '../../src/node-utils';

export const serializer: Plugin = {
test: (val: unknown): val is TSError => val instanceof TSError,
Expand Down