Skip to content

Repo: Split up parse.test.ts test to be more parallelizeable  #6025

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Suggestion

Within packages/typescript-estree, parse.test.ts takes about ~11 seconds on average on my M2 Macbook Air. That's quite a lot of time to spend on one test file.

I set the slowTestThreshold to 0 and ran it locally. Here are the tests that took >100ms:

parseAndGenerateServices
  preserveNodeMaps
    ✓ should preserve node maps by default for parseAndGenerateServices() (666 ms)
    project includes
      ✓ doesn't error for matched files (484 ms)
  invalid project error messages
    ✓ throws when non of multiple projects include the file (507 ms)
  projectFolderIgnoreList
    ✓ ignores nothing when given nothing (897 ms)
    ✓ ignores a folder when given a string glob (431 ms)
  moduleResolver
    when file is in the project
      ✓ returns error if __PLACEHOLDER__ can not be resolved (1998 ms)
      ✓ resolves __PLACEHOLDER__ correctly (1903 ms)
    when file is not in the project and createDefaultProgram=true
      ✓ returns error because __PLACEHOLDER__ can not be resolved (1607 ms)
      ✓ resolves __PLACEHOLDER__ correctly (1740 ms)

Proposal: let's move each of the groups inside parseAndGenerateServices to their own test file? For example, parse.moduleResolver.test.ts? That way test runners able to parallelize test running across different cores will be able to make these tests run more in parallel. I applied a similar change in #4599.

Full output from yarn jest lib/parse.test.ts --verbose ```plaintext PASS tests/lib/parse.test.ts (10.879 s) parseWithNodeMaps() basic functionality ✓ should parse an empty string (6 ms) ✓ parse() should be the same as parseWithNodeMaps().ast (5 ms) ✓ should simple code (3 ms) modules ✓ should have correct column number when strict mode error occurs (1 ms) general ✓ output tokens, comments, locs, and ranges when called with those options (2 ms) ✓ output should not contain loc (1 ms) ✓ output should not contain range (1 ms) non string code ✓ should correctly convert code to a string for parse() (1 ms) ✓ should correctly convert code to a string for parseAndGenerateServices() (3 ms) loggerFn should be propagated to ast-converter ✓ output tokens, comments, locs, and ranges when called with those options (1 ms) parseAndGenerateServices errorOnTypeScriptSyntacticAndSemanticIssues ✓ should throw on invalid option when used in parseWithNodeMaps (8 ms) ✓ should not throw when used in parseAndGenerateServices (24 ms) ✓ should error on invalid code (2 ms) preserveNodeMaps ✓ should not impact the use of parse() (3 ms) ✓ should not impact the use of parseWithNodeMaps() (2 ms) ✓ should preserve node maps by default for parseAndGenerateServices() (666 ms) should preserve node maps for parseAndGenerateServices() when option is `true`, regardless of `project` config ✓ without project (1 ms) ✓ with project (1 ms) should not preserve node maps for parseAndGenerateServices() when option is `false`, regardless of `project` config ✓ without project ✓ with project isolated parsing ✓ should parse .js file - without JSX content - parserOptions.jsx = false (1 ms) ✓ should parse .js file - without JSX content - parserOptions.jsx = true (3 ms) ✓ should parse .js file - with JSX content - parserOptions.jsx = false (4 ms) ✓ should parse .js file - with JSX content - parserOptions.jsx = true (2 ms) ✓ should parse .jsx file - without JSX content - parserOptions.jsx = false (4 ms) ✓ should parse .jsx file - without JSX content - parserOptions.jsx = true (1 ms) ✓ should parse .jsx file - with JSX content - parserOptions.jsx = false (1 ms) ✓ should parse .jsx file - with JSX content - parserOptions.jsx = true (1 ms) ✓ should parse .ts file - without JSX content - parserOptions.jsx = false ✓ should parse .ts file - without JSX content - parserOptions.jsx = true (1 ms) ✓ should parse .ts file - with JSX content - parserOptions.jsx = false (2 ms) ✓ should parse .ts file - with JSX content - parserOptions.jsx = true (1 ms) ✓ should parse .tsx file - without JSX content - parserOptions.jsx = false (1 ms) ✓ should parse .tsx file - without JSX content - parserOptions.jsx = true (1 ms) ✓ should parse .tsx file - with JSX content - parserOptions.jsx = false (2 ms) ✓ should parse .tsx file - with JSX content - parserOptions.jsx = true (1 ms) ✓ should parse .vue file - without JSX content - parserOptions.jsx = false (1 ms) ✓ should parse .vue file - without JSX content - parserOptions.jsx = true (1 ms) ✓ should parse .vue file - with JSX content - parserOptions.jsx = false ✓ should parse .vue file - with JSX content - parserOptions.jsx = true (1 ms) ✓ should parse .json file - without JSX content - parserOptions.jsx = false (1 ms) invalid file error messages project includes ✓ doesn't error for matched files (484 ms) ✓ errors for not included files (2 ms) "parserOptions.extraFileExtensions" is empty ✓ should not error ✓ the extension does not match "parserOptions.extraFileExtensions" is non-empty ✓ invalid extension ✓ the extension does not match the extension matches ✓ the file is included (3 ms) ✓ the file isn't included (1 ms) ✓ duplicate extension invalid project error messages ✓ throws when non of multiple projects include the file (507 ms) debug options ✓ shouldn't turn on debugger if no options were provided (1 ms) ✓ should turn on eslint debugger (1 ms) ✓ should turn on typescript-eslint debugger ✓ should turn on both eslint and typescript-eslint debugger (1 ms) ✓ should turn on typescript debugger projectFolderIgnoreList ✓ ignores nothing when given nothing (897 ms) ✓ ignores a folder when given a string glob (431 ms) moduleResolver when file is in the project ✓ returns error if __PLACEHOLDER__ can not be resolved (1998 ms) ✓ throws error if moduleResolver can not be found (2 ms) ✓ resolves __PLACEHOLDER__ correctly (1903 ms) when file is not in the project and createDefaultProgram=true ✓ returns error because __PLACEHOLDER__ can not be resolved (1607 ms) ✓ resolves __PLACEHOLDER__ correctly (1740 ms) ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuegood first issueGood for newcomersrepo maintenancethings to do with maintenance of the repo, and not with code/docs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions