diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 5ec5318d188..d193e76947b 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -57,9 +57,5 @@ module.exports = { '@typescript-eslint/sort-type-union-intersection-members': 'error', }, }, - { - files: '**/__tests__/*-test.js', - env: { jest: true }, - }, ], }; diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 272b040f640..9bdb841e70c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: tests: strategy: matrix: - node: ['14.15.0', '16', '18'] + node: ['14.17.0', '16', '18'] os: ['ubuntu'] include: - os: macos @@ -37,19 +37,19 @@ jobs: node-version: ${{ matrix.node }} cache: 'yarn' - - uses: actions/cache@v3 - name: Cache jest cache - with: - path: .jest-cache - key: ${{ runner.os }}-${{ matrix.node }}-jest - - name: Install dependencies run: yarn install --immutable + - name: Unit tests with coverage + if: '${{ matrix.node == env.NODE_VERSION }}' + run: yarn test --coverage + - name: Unit tests - run: yarn test:ci + if: '${{ matrix.node != env.NODE_VERSION }}' + run: yarn test - name: Upload coverage to Codecov + if: '${{ matrix.node == env.NODE_VERSION }}' uses: codecov/codecov-action@v3 lint: @@ -90,6 +90,9 @@ jobs: - name: Install dependencies run: yarn install --immutable + - name: Build + run: yarn build + - name: Build website run: yarn website:build @@ -114,6 +117,9 @@ jobs: run: yarn install --immutable - name: Build + run: yarn build + + - name: Build website run: yarn website:build - name: Deploy diff --git a/.gitignore b/.gitignore index c46f98ccec6..b0abdf07eb7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ dist node_modules/ .idea/ -.jest-cache/ coverage/ yarn-error.log .pnp.* diff --git a/benchmark/__fixtures__/CircularProgress.js b/benchmark/__fixtures__/CircularProgress.js index e2c42bdab43..5163df48db4 100644 --- a/benchmark/__fixtures__/CircularProgress.js +++ b/benchmark/__fixtures__/CircularProgress.js @@ -2,8 +2,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import { chainPropTypes } from '@material-ui/utils'; -import withStyles from '../styles/withStyles'; -import { capitalize } from '../utils/helpers'; +import withStyles from '../styles/withStyles.js'; +import { capitalize } from '../utils/helpers.js'; const SIZE = 44; diff --git a/package.json b/package.json index 4b9cead53c1..b5783a37bff 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,16 @@ { "private": true, "engines": { - "node": ">=14.15.0", + "node": ">=14.17.0", "yarn": ">=3.2.2" }, "scripts": { - "build": "yarn --verbose workspaces foreach --exclude 'benchmark' --exclude 'website' -p run build", + "build": "yarn --verbose workspaces foreach --exclude 'benchmark' --exclude 'website' run build", + "watch": "yarn --verbose workspaces foreach --exclude 'benchmark' --exclude 'website' -p run watch", "lint": "eslint . --ext .js,.ts --report-unused-disable-directives", "fix": "eslint . --ext .js,.ts --fix --report-unused-disable-directives", - "test": "yarn build && jest", - "test:ci": "yarn build && jest --ci --cacheDirectory $(pwd)/.jest-cache/ --coverage", + "test": "yarn build && vitest run", + "test:dev": "vitest", "website:build": "yarn workspace website run build", "website:start": "yarn workspace website run start" }, @@ -21,22 +22,18 @@ ], "devDependencies": { "@types/cross-spawn": "6.0.2", - "@types/jest": "29.2.3", "@types/rimraf": "3.0.2", "@typescript-eslint/eslint-plugin": "5.44.0", "@typescript-eslint/parser": "5.44.0", - "cross-spawn": "7.0.3", + "@vitest/coverage-c8": "0.25.3", "eslint": "8.28.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-prettier": "4.2.1", - "jest": "29.3.1", - "jest-diff": "29.3.1", - "jest-matcher-utils": "29.3.1", "prettier": "2.8.0", "rimraf": "3.0.2", "tempy": "1.0.1", - "ts-jest": "29.0.3", - "typescript": "4.9.3" + "typescript": "4.9.3", + "vitest": "0.25.3" }, "packageManager": "yarn@3.3.0" } diff --git a/packages/react-docgen-cli/jest.config.mjs b/packages/react-docgen-cli/jest.config.mjs deleted file mode 100644 index d2aec01c9f2..00000000000 --- a/packages/react-docgen-cli/jest.config.mjs +++ /dev/null @@ -1,10 +0,0 @@ -export default { - displayName: { - name: 'react-docgen-cli', - color: 'yellow', - }, - collectCoverageFrom: ['src/**/*.ts', '!**/__tests__/**', '!**/__mocks__/**'], - coverageReporters: ['cobertura', 'text'], - preset: 'ts-jest', - testRegex: '/__tests__/.*-test\\.ts$', -}; diff --git a/packages/react-docgen-cli/package.json b/packages/react-docgen-cli/package.json index e0270487325..64b654c451b 100644 --- a/packages/react-docgen-cli/package.json +++ b/packages/react-docgen-cli/package.json @@ -3,6 +3,7 @@ "version": "6.0.0-alpha.3", "description": "A CLI and toolkit to extract information from React components for documentation generation.", "repository": "reactjs/react-docgen", + "type": "module", "bin": { "react-docgen": "bin/react-docgen.js" }, @@ -10,11 +11,11 @@ "bin" ], "engines": { - "node": ">=14.15.0" + "node": ">=14.17.0" }, "scripts": { "build": "echo 'done'", - "test": "yarn build && jest" + "watch": "echo 'done'" }, "keywords": [ "react", diff --git a/packages/react-docgen-cli/src/__tests__/react-docgen-test.ts b/packages/react-docgen-cli/src/__tests__/react-docgen-test.ts index b46e0c64193..55c0d2df1b6 100644 --- a/packages/react-docgen-cli/src/__tests__/react-docgen-test.ts +++ b/packages/react-docgen-cli/src/__tests__/react-docgen-test.ts @@ -8,6 +8,7 @@ import path from 'path'; import rimraf from 'rimraf'; import { directory as tempDirectory, file as tempFile } from 'tempy'; import spawn from 'cross-spawn'; +import { afterEach, describe, expect, test } from 'vitest'; const { writeFile, mkdir } = promises; @@ -85,7 +86,7 @@ describe.skip('react-docgen CLI', () => { tempNoComponents = []; }, TEST_TIMEOUT); - it( + test( 'reads from stdin', async () => { return run([], component).then(([stdout, stderr]) => { @@ -96,7 +97,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'reads files provided as command line arguments', async () => { await createTempfiles(); @@ -110,7 +111,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'reads directories provided as command line arguments', async () => { await createTempfiles(); @@ -122,7 +123,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'considers js and jsx by default', async () => { await createTempfiles(); @@ -141,7 +142,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'considers files with the specified extension', async () => { await createTempfiles('foo'); @@ -162,7 +163,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'considers files with the specified extension shortcut', async () => { await createTempfiles('foo'); @@ -179,7 +180,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'ignores files in node_modules, __tests__ and __mocks__ by default', async () => { await createTempfiles(undefined, 'node_modules'); @@ -194,7 +195,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'ignores specified folders', async () => { await createTempfiles(undefined, 'foo'); @@ -207,7 +208,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'ignores specified folders shortcut', async () => { await createTempfiles(undefined, 'foo'); @@ -220,7 +221,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'writes to stdout', async () => { const [stdout, stderr] = await run([], component); @@ -231,7 +232,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'writes to stderr', async () => { const [stdout, stderr] = await run([], '{}'); @@ -242,7 +243,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'writes to a file if provided', async () => { const outFile = tempFile(); @@ -257,7 +258,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'writes to a file if provided shortcut', async () => { const outFile = tempFile(); @@ -274,7 +275,7 @@ describe.skip('react-docgen CLI', () => { describe('--resolver', () => { describe('accepts the names of built in resolvers', () => { - it( + test( 'findExportedComponentDefinition (default)', async () => { // No option passed: same as --resolver=findExportedComponentDefinition @@ -287,7 +288,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'findExportedComponentDefinition', async () => { const [stdout] = await run([ @@ -300,7 +301,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'findAllComponentDefinitions', async () => { const [stdout] = await run([ @@ -314,7 +315,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'findAllExportedComponentDefinitions', async () => { const [stdout] = await run([ @@ -329,7 +330,7 @@ describe.skip('react-docgen CLI', () => { ); }); - it( + test( 'accepts a path to a resolver function', async () => { const [stdout] = await run([ @@ -347,7 +348,7 @@ describe.skip('react-docgen CLI', () => { }); describe('--exclude/-e', () => { - it( + test( 'ignores files by name', async () => { await createTempfiles(undefined, 'foo'); @@ -365,7 +366,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'ignores files by name shortcut', async () => { await createTempfiles(undefined, 'foo'); @@ -385,7 +386,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'ignores files by regex', async () => { await createTempfiles(undefined, 'foo'); @@ -402,7 +403,7 @@ describe.skip('react-docgen CLI', () => { TEST_TIMEOUT, ); - it( + test( 'ignores files by regex shortcut', async () => { await createTempfiles(undefined, 'foo'); diff --git a/packages/react-docgen/jest.config.mjs b/packages/react-docgen/jest.config.mjs deleted file mode 100644 index c366b8ea4ab..00000000000 --- a/packages/react-docgen/jest.config.mjs +++ /dev/null @@ -1,12 +0,0 @@ -export default { - displayName: { - name: 'react-docgen', - color: 'blue', - }, - collectCoverageFrom: ['src/**/*.ts', '!**/__tests__/**', '!**/__mocks__/**'], - coverageReporters: ['cobertura', 'text'], - snapshotSerializers: ['./tests/NodePathSerializer.js'], - setupFilesAfterEnv: ['./tests/setupTestFramework.ts'], - preset: 'ts-jest', - testRegex: '(/__tests__/|/tests/integration/).*-test\\.ts$', -}; diff --git a/packages/react-docgen/package.json b/packages/react-docgen/package.json index 77c79a54a1b..166bd68ec70 100644 --- a/packages/react-docgen/package.json +++ b/packages/react-docgen/package.json @@ -3,21 +3,22 @@ "version": "6.0.0-alpha.3", "description": "A library to extract information from React components for documentation generation.", "repository": "reactjs/react-docgen", + "type": "module", "browser": { - "./dist/importer/makeFsImporter.js": "./dist/importer/makeIgnoreImports.js", - "./src/importer/makeFsImporter.ts": "./src/importer/makeIgnoreImports.ts" + "./dist/importer/fsImporter.js": "./dist/importer/ignoreImports.js", + "./src/importer/fsImporter.ts": "./src/importer/ignoreImports.ts" }, "files": [ "dist" ], "engines": { - "node": ">=14.15.0" + "node": ">=14.17.0" }, "main": "dist/main.js", "typings": "dist/main.d.ts", "scripts": { "build": "rimraf dist/ && tsc", - "test": "yarn build && jest" + "watch": "rimraf dist/ && tsc --watch" }, "keywords": [ "react", diff --git a/packages/react-docgen/src/FileState.ts b/packages/react-docgen/src/FileState.ts index 47717b642b9..b1e018fd889 100644 --- a/packages/react-docgen/src/FileState.ts +++ b/packages/react-docgen/src/FileState.ts @@ -1,8 +1,8 @@ import type { HubInterface, Scope, Visitor } from '@babel/traverse'; import traverse, { NodePath } from '@babel/traverse'; import type { File, Node, Program } from '@babel/types'; -import type { Importer, ImportPath } from './importer'; -import babelParse from './babelParser'; +import type { Importer, ImportPath } from './importer/index.js'; +import babelParse from './babelParser.js'; import type { TransformOptions } from '@babel/core'; export default class FileState { @@ -85,6 +85,6 @@ export default class FileState { * Traverse the current file */ traverse(visitors: Visitor, state?: unknown): void { - traverse(this.ast, visitors, this.scope, state); + traverse.default(this.ast, visitors, this.scope, state); } } diff --git a/packages/react-docgen/src/__tests__/__snapshots__/main-test.ts.snap b/packages/react-docgen/src/__tests__/__snapshots__/main-test.ts.snap index 52fd436c0c3..01d0b54c5eb 100644 --- a/packages/react-docgen/src/__tests__/__snapshots__/main-test.ts.snap +++ b/packages/react-docgen/src/__tests__/__snapshots__/main-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`main Class definition parses with custom handlers 1`] = ` +exports[`main > Class definition > parses with custom handlers 1`] = ` [ { "description": "Example component description", @@ -8,7 +8,7 @@ exports[`main Class definition parses with custom handlers 1`] = ` ] `; -exports[`main Class definition parses with default resolver/handlers 1`] = ` +exports[`main > Class definition > parses with default resolver/handlers 1`] = ` [ { "description": "Example component description", @@ -31,7 +31,7 @@ exports[`main Class definition parses with default resolver/handlers 1`] = ` ] `; -exports[`main React.createClass parses with custom handlers 1`] = ` +exports[`main > React.createClass > parses with custom handlers 1`] = ` [ { "description": "Example component description", @@ -39,7 +39,7 @@ exports[`main React.createClass parses with custom handlers 1`] = ` ] `; -exports[`main React.createClass parses with default resolver/handlers 1`] = ` +exports[`main > React.createClass > parses with default resolver/handlers 1`] = ` [ { "description": "Example component description", @@ -70,7 +70,7 @@ exports[`main React.createClass parses with default resolver/handlers 1`] = ` ] `; -exports[`main Stateless Component definition: ArrowFunctionExpression parses with custom handlers 1`] = ` +exports[`main > Stateless Component definition: ArrowFunctionExpression > parses with custom handlers 1`] = ` [ { "description": "Example component description", @@ -78,7 +78,7 @@ exports[`main Stateless Component definition: ArrowFunctionExpression parses wit ] `; -exports[`main Stateless Component definition: ArrowFunctionExpression parses with default resolver/handlers 1`] = ` +exports[`main > Stateless Component definition: ArrowFunctionExpression > parses with default resolver/handlers 1`] = ` [ { "description": "Example component description", @@ -101,7 +101,7 @@ exports[`main Stateless Component definition: ArrowFunctionExpression parses wit ] `; -exports[`main Stateless Component definition: FunctionDeclaration parses with custom handlers 1`] = ` +exports[`main > Stateless Component definition: FunctionDeclaration > parses with custom handlers 1`] = ` [ { "description": "Example component description", @@ -109,7 +109,7 @@ exports[`main Stateless Component definition: FunctionDeclaration parses with cu ] `; -exports[`main Stateless Component definition: FunctionDeclaration parses with default resolver/handlers 1`] = ` +exports[`main > Stateless Component definition: FunctionDeclaration > parses with default resolver/handlers 1`] = ` [ { "description": "Example component description", @@ -132,7 +132,7 @@ exports[`main Stateless Component definition: FunctionDeclaration parses with de ] `; -exports[`main Stateless Component definition: FunctionExpression parses with custom handlers 1`] = ` +exports[`main > Stateless Component definition: FunctionExpression > parses with custom handlers 1`] = ` [ { "description": "Example component description", @@ -140,7 +140,7 @@ exports[`main Stateless Component definition: FunctionExpression parses with cus ] `; -exports[`main Stateless Component definition: FunctionExpression parses with default resolver/handlers 1`] = ` +exports[`main > Stateless Component definition: FunctionExpression > parses with default resolver/handlers 1`] = ` [ { "description": "Example component description", diff --git a/packages/react-docgen/src/__tests__/main-test.ts b/packages/react-docgen/src/__tests__/main-test.ts index cfba94d69eb..7a55b1b425a 100644 --- a/packages/react-docgen/src/__tests__/main-test.ts +++ b/packages/react-docgen/src/__tests__/main-test.ts @@ -1,16 +1,17 @@ -import { handlers, parse } from '../main'; -import { ERROR_MISSING_DEFINITION } from '../parse'; +import { handlers, parse } from '../main.js'; +import { ERROR_MISSING_DEFINITION } from '../parse.js'; +import { describe, expect, test } from 'vitest'; // TODO make fixtures out of them? describe('main', () => { - function test(source: string) { - it('parses with default resolver/handlers', () => { + function testMain(source: string) { + test('parses with default resolver/handlers', () => { const docs = parse(source); expect(docs).toMatchSnapshot(); }); - it('parses with custom handlers', () => { + test('parses with custom handlers', () => { const docs = parse(source, { handlers: [handlers.componentDocblockHandler], }); @@ -20,7 +21,7 @@ describe('main', () => { } describe('React.createClass', () => { - test(` + testMain(` var React = require("react"); var PropTypes = React.PropTypes; @@ -49,7 +50,7 @@ describe('main', () => { }); describe('Class definition', () => { - test(` + testMain(` const React = require("react"); const PropTypes = React.PropTypes; @@ -76,7 +77,7 @@ describe('main', () => { }); describe('Stateless Component definition: ArrowFunctionExpression', () => { - test(` + testMain(` import React, {PropTypes} from "react"; const defaultProps = { @@ -102,7 +103,7 @@ describe('main', () => { }); describe('Stateless Component definition: FunctionDeclaration', () => { - test(` + testMain(` import React, {PropTypes} from "react"; const defaultProps = { @@ -131,7 +132,7 @@ describe('main', () => { }); describe('Stateless Component definition: FunctionExpression', () => { - test(` + testMain(` import React, {PropTypes} from "react"; const defaultProps = { @@ -160,7 +161,7 @@ describe('main', () => { }); describe('Stateless Component definition', () => { - it('is not so greedy', () => { + test('is not so greedy', () => { const source = ` import React, {PropTypes} from "react"; diff --git a/packages/react-docgen/src/__tests__/parse-test.ts b/packages/react-docgen/src/__tests__/parse-test.ts index 36e2b3e920a..78aa6b2c326 100644 --- a/packages/react-docgen/src/__tests__/parse-test.ts +++ b/packages/react-docgen/src/__tests__/parse-test.ts @@ -2,13 +2,14 @@ import type { ObjectExpression } from '@babel/types'; import fs from 'fs'; import { directory as tempDirectory } from 'tempy'; import { parse as testParse, noopImporter } from '../../tests/utils'; -import parse, { ERROR_MISSING_DEFINITION } from '../parse'; +import parse, { ERROR_MISSING_DEFINITION } from '../parse.js'; +import { describe, expect, test, vi } from 'vitest'; describe('parse', () => { - it('allows custom component definition resolvers', () => { + test('allows custom component definition resolvers', () => { const path = testParse.expression('{foo: "bar"}'); - const resolver = jest.fn(() => [path]); - const handler = jest.fn(); + const resolver = vi.fn(() => [path]); + const handler = vi.fn(); parse('//empty', { resolver, @@ -21,8 +22,8 @@ describe('parse', () => { expect(handler.mock.calls[0][1]).toBe(path); }); - it('errors if component definition is not found', () => { - const resolver = jest.fn(() => []); + test('errors if component definition is not found', () => { + const resolver = vi.fn(() => []); expect(() => parse('//empty', { @@ -45,7 +46,7 @@ describe('parse', () => { expect(resolver).toBeCalled(); }); - it('uses local babelrc', () => { + test('uses local babelrc', () => { const dir = tempDirectory(); try { @@ -68,7 +69,7 @@ describe('parse', () => { } }); - it('supports custom parserOptions with plugins', () => { + test('supports custom parserOptions with plugins', () => { expect(() => parse('const chained: Type = 1;', { resolver: () => [], @@ -86,7 +87,7 @@ describe('parse', () => { ).toThrowError(/.*\(1:13\).*/); }); - it('supports custom parserOptions without plugins', () => { + test('supports custom parserOptions without plugins', () => { expect(() => parse('const chained: Type = 1;', { resolver: () => [], diff --git a/packages/react-docgen/src/config.ts b/packages/react-docgen/src/config.ts index 3d01ed32628..1ec8abcc937 100644 --- a/packages/react-docgen/src/config.ts +++ b/packages/react-docgen/src/config.ts @@ -1,5 +1,5 @@ import type { TransformOptions } from '@babel/core'; -import type { Handler } from './handlers'; +import type { Handler } from './handlers/index.js'; import { childContextTypeHandler, codeTypeHandler, @@ -12,11 +12,11 @@ import { propDocBlockHandler, propTypeCompositionHandler, propTypeHandler, -} from './handlers'; -import type { Importer } from './importer'; -import { fsImporter } from './importer'; -import type { Resolver } from './resolver'; -import { findExportedComponentDefinition } from './resolver'; +} from './handlers/index.js'; +import type { Importer } from './importer/index.js'; +import { fsImporter } from './importer/index.js'; +import type { Resolver } from './resolver/index.js'; +import { findExportedComponentDefinition } from './resolver/index.js'; export interface Config { handlers?: Handler[]; diff --git a/packages/react-docgen/src/handlers/__tests__/__snapshots__/codeTypeHandler-test.ts.snap b/packages/react-docgen/src/handlers/__tests__/__snapshots__/codeTypeHandler-test.ts.snap index cfb552bcbf8..e706f9a9d66 100644 --- a/packages/react-docgen/src/handlers/__tests__/__snapshots__/codeTypeHandler-test.ts.snap +++ b/packages/react-docgen/src/handlers/__tests__/__snapshots__/codeTypeHandler-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`codeTypeHandler TypeAlias class definition for flow <0.53 ignores hash map entry 1`] = ` +exports[`codeTypeHandler > TypeAlias > class definition for flow <0.53 > ignores hash map entry 1`] = ` { "bar": { "description": "", @@ -10,7 +10,7 @@ exports[`codeTypeHandler TypeAlias class definition for flow <0.53 ignores hash } `; -exports[`codeTypeHandler TypeAlias class definition for flow >=0.53 with State ignores hash map entry 1`] = ` +exports[`codeTypeHandler > TypeAlias > class definition for flow >=0.53 with State > ignores hash map entry 1`] = ` { "bar": { "description": "", @@ -20,7 +20,7 @@ exports[`codeTypeHandler TypeAlias class definition for flow >=0.53 with State i } `; -exports[`codeTypeHandler TypeAlias class definition for flow >=0.53 without State ignores hash map entry 1`] = ` +exports[`codeTypeHandler > TypeAlias > class definition for flow >=0.53 without State > ignores hash map entry 1`] = ` { "bar": { "description": "", @@ -30,7 +30,7 @@ exports[`codeTypeHandler TypeAlias class definition for flow >=0.53 without Stat } `; -exports[`codeTypeHandler TypeAlias class definition with inline props ignores hash map entry 1`] = ` +exports[`codeTypeHandler > TypeAlias > class definition with inline props > ignores hash map entry 1`] = ` { "bar": { "description": "", @@ -40,7 +40,7 @@ exports[`codeTypeHandler TypeAlias class definition with inline props ignores ha } `; -exports[`codeTypeHandler TypeAlias stateless component ignores hash map entry 1`] = ` +exports[`codeTypeHandler > TypeAlias > stateless component > ignores hash map entry 1`] = ` { "bar": { "description": "", @@ -50,7 +50,7 @@ exports[`codeTypeHandler TypeAlias stateless component ignores hash map entry 1` } `; -exports[`codeTypeHandler does support utility types inline 1`] = ` +exports[`codeTypeHandler > does support utility types inline 1`] = ` { "foo": { "description": "", @@ -60,7 +60,7 @@ exports[`codeTypeHandler does support utility types inline 1`] = ` } `; -exports[`codeTypeHandler imported prop types imported 1`] = ` +exports[`codeTypeHandler > imported prop types > imported 1`] = ` { "abc": { "description": "", @@ -95,7 +95,7 @@ exports[`codeTypeHandler imported prop types imported 1`] = ` } `; -exports[`codeTypeHandler imported prop types type imported 1`] = ` +exports[`codeTypeHandler > imported prop types > type imported 1`] = ` { "abc": { "description": "", diff --git a/packages/react-docgen/src/handlers/__tests__/__snapshots__/componentMethodsHandler-test.ts.snap b/packages/react-docgen/src/handlers/__tests__/__snapshots__/componentMethodsHandler-test.ts.snap index e7a7a858ba2..d3ede952c04 100644 --- a/packages/react-docgen/src/handlers/__tests__/__snapshots__/componentMethodsHandler-test.ts.snap +++ b/packages/react-docgen/src/handlers/__tests__/__snapshots__/componentMethodsHandler-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`componentMethodsHandler function components finds static methods on a component in a variable declaration 1`] = ` +exports[`componentMethodsHandler > function components > finds static methods on a component in a variable declaration 1`] = ` [ { "docblock": null, @@ -23,7 +23,7 @@ exports[`componentMethodsHandler function components finds static methods on a c ] `; -exports[`componentMethodsHandler function components finds static methods on a component in an assignment 1`] = ` +exports[`componentMethodsHandler > function components > finds static methods on a component in an assignment 1`] = ` [ { "docblock": null, @@ -46,7 +46,7 @@ exports[`componentMethodsHandler function components finds static methods on a c ] `; -exports[`componentMethodsHandler function components finds static methods on a function declaration 1`] = ` +exports[`componentMethodsHandler > function components > finds static methods on a function declaration 1`] = ` [ { "docblock": null, @@ -69,7 +69,7 @@ exports[`componentMethodsHandler function components finds static methods on a f ] `; -exports[`componentMethodsHandler function components resolves imported methods assigned on a component in an assignment 1`] = ` +exports[`componentMethodsHandler > function components > resolves imported methods assigned on a component in an assignment 1`] = ` [ { "docblock": null, @@ -83,7 +83,7 @@ exports[`componentMethodsHandler function components resolves imported methods a ] `; -exports[`componentMethodsHandler function components resolves imported methods assigned to static properties on a component 1`] = ` +exports[`componentMethodsHandler > function components > resolves imported methods assigned to static properties on a component 1`] = ` [ { "docblock": null, @@ -97,7 +97,7 @@ exports[`componentMethodsHandler function components resolves imported methods a ] `; -exports[`componentMethodsHandler function components resolves imported methods on a function declaration 1`] = ` +exports[`componentMethodsHandler > function components > resolves imported methods on a function declaration 1`] = ` [ { "docblock": null, @@ -111,7 +111,7 @@ exports[`componentMethodsHandler function components resolves imported methods o ] `; -exports[`componentMethodsHandler resolves imported methods assigned to computed properties 1`] = ` +exports[`componentMethodsHandler > resolves imported methods assigned to computed properties 1`] = ` [ { "docblock": "The foo method", @@ -135,7 +135,7 @@ exports[`componentMethodsHandler resolves imported methods assigned to computed ] `; -exports[`componentMethodsHandler should handle and ignore computed methods 1`] = ` +exports[`componentMethodsHandler > should handle and ignore computed methods 1`] = ` [ { "docblock": "The foo method", @@ -159,7 +159,7 @@ exports[`componentMethodsHandler should handle and ignore computed methods 1`] = ] `; -exports[`componentMethodsHandler useImperativeHandle AssignmentExpression and useImperativeHandle 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > AssignmentExpression and useImperativeHandle 1`] = ` [ { "docblock": null, @@ -180,7 +180,7 @@ exports[`componentMethodsHandler useImperativeHandle AssignmentExpression and us ] `; -exports[`componentMethodsHandler useImperativeHandle VariableDeclaration and useImperativeHandle 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > VariableDeclaration and useImperativeHandle 1`] = ` [ { "docblock": null, @@ -201,7 +201,7 @@ exports[`componentMethodsHandler useImperativeHandle VariableDeclaration and use ] `; -exports[`componentMethodsHandler useImperativeHandle assigned ReturnStatement ArrowFunctionExpression Component 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > assigned ReturnStatement > ArrowFunctionExpression Component 1`] = ` [ { "docblock": null, @@ -213,7 +213,7 @@ exports[`componentMethodsHandler useImperativeHandle assigned ReturnStatement Ar ] `; -exports[`componentMethodsHandler useImperativeHandle assigned ReturnStatement FunctionDeclaration Component 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > assigned ReturnStatement > FunctionDeclaration Component 1`] = ` [ { "docblock": null, @@ -225,7 +225,7 @@ exports[`componentMethodsHandler useImperativeHandle assigned ReturnStatement Fu ] `; -exports[`componentMethodsHandler useImperativeHandle assigned ReturnStatement FunctionExpression Component 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > assigned ReturnStatement > FunctionExpression Component 1`] = ` [ { "docblock": null, @@ -237,7 +237,7 @@ exports[`componentMethodsHandler useImperativeHandle assigned ReturnStatement Fu ] `; -exports[`componentMethodsHandler useImperativeHandle direct ObjectExpression ArrowFunctionExpression Component 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > direct ObjectExpression > ArrowFunctionExpression Component 1`] = ` [ { "docblock": null, @@ -249,7 +249,7 @@ exports[`componentMethodsHandler useImperativeHandle direct ObjectExpression Arr ] `; -exports[`componentMethodsHandler useImperativeHandle direct ObjectExpression FunctionDeclaration Component 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > direct ObjectExpression > FunctionDeclaration Component 1`] = ` [ { "docblock": null, @@ -261,7 +261,7 @@ exports[`componentMethodsHandler useImperativeHandle direct ObjectExpression Fun ] `; -exports[`componentMethodsHandler useImperativeHandle direct ObjectExpression FunctionExpression Component 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > direct ObjectExpression > FunctionExpression Component 1`] = ` [ { "docblock": null, @@ -273,7 +273,7 @@ exports[`componentMethodsHandler useImperativeHandle direct ObjectExpression Fun ] `; -exports[`componentMethodsHandler useImperativeHandle regular ReturnStatement ArrowFunctionExpression Component 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > regular ReturnStatement > ArrowFunctionExpression Component 1`] = ` [ { "docblock": null, @@ -285,7 +285,7 @@ exports[`componentMethodsHandler useImperativeHandle regular ReturnStatement Arr ] `; -exports[`componentMethodsHandler useImperativeHandle regular ReturnStatement FunctionDeclaration Component 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > regular ReturnStatement > FunctionDeclaration Component 1`] = ` [ { "docblock": null, @@ -297,7 +297,7 @@ exports[`componentMethodsHandler useImperativeHandle regular ReturnStatement Fun ] `; -exports[`componentMethodsHandler useImperativeHandle regular ReturnStatement FunctionExpression Component 1`] = ` +exports[`componentMethodsHandler > useImperativeHandle > regular ReturnStatement > FunctionExpression Component 1`] = ` [ { "docblock": null, diff --git a/packages/react-docgen/src/handlers/__tests__/__snapshots__/componentMethodsJsDocHandler-test.ts.snap b/packages/react-docgen/src/handlers/__tests__/__snapshots__/componentMethodsJsDocHandler-test.ts.snap index 6e12526b76e..ba289a067f2 100644 --- a/packages/react-docgen/src/handlers/__tests__/__snapshots__/componentMethodsJsDocHandler-test.ts.snap +++ b/packages/react-docgen/src/handlers/__tests__/__snapshots__/componentMethodsJsDocHandler-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`componentMethodsJsDocHandler adds descriptions 1`] = ` +exports[`componentMethodsJsDocHandler > adds descriptions 1`] = ` [ { "description": "The foo method.", @@ -27,7 +27,7 @@ exports[`componentMethodsJsDocHandler adds descriptions 1`] = ` ] `; -exports[`componentMethodsJsDocHandler adds js doc types when no flow types 1`] = ` +exports[`componentMethodsJsDocHandler > adds js doc types when no flow types 1`] = ` [ { "description": null, @@ -57,7 +57,7 @@ exports[`componentMethodsJsDocHandler adds js doc types when no flow types 1`] = ] `; -exports[`componentMethodsJsDocHandler keeps flow types over js doc types 1`] = ` +exports[`componentMethodsJsDocHandler > keeps flow types over js doc types 1`] = ` [ { "description": null, diff --git a/packages/react-docgen/src/handlers/__tests__/__snapshots__/defaultPropsHandler-test.ts.snap b/packages/react-docgen/src/handlers/__tests__/__snapshots__/defaultPropsHandler-test.ts.snap index 1b311851699..cf26ab28258 100644 --- a/packages/react-docgen/src/handlers/__tests__/__snapshots__/defaultPropsHandler-test.ts.snap +++ b/packages/react-docgen/src/handlers/__tests__/__snapshots__/defaultPropsHandler-test.ts.snap @@ -1,34 +1,34 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`defaultPropsHandler ClassDeclaration with static defaultProps can resolve default props that are imported given a custom importer 1`] = ` +exports[`defaultPropsHandler > ClassDeclaration with static defaultProps > can resolve default props that are imported given a custom importer 1`] = ` { "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, } `; -exports[`defaultPropsHandler ClassDeclaration with static defaultProps resolves imported spreads 1`] = ` +exports[`defaultPropsHandler > ClassDeclaration with static defaultProps > resolves imported spreads 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ClassDeclaration with static defaultProps resolves imported values assigned as default props 1`] = ` +exports[`defaultPropsHandler > ClassDeclaration with static defaultProps > resolves imported values assigned as default props 1`] = ` { "abc": { "defaultValue": { @@ -45,19 +45,19 @@ exports[`defaultPropsHandler ClassDeclaration with static defaultProps resolves "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ClassDeclaration with static defaultProps should find prop default values that are imported variables 1`] = ` +exports[`defaultPropsHandler > ClassDeclaration with static defaultProps > should find prop default values that are imported variables 1`] = ` { "foo": { "defaultValue": { @@ -68,7 +68,7 @@ exports[`defaultPropsHandler ClassDeclaration with static defaultProps should fi } `; -exports[`defaultPropsHandler ClassDeclaration with static defaultProps should find prop default values that are literals 1`] = ` +exports[`defaultPropsHandler > ClassDeclaration with static defaultProps > should find prop default values that are literals 1`] = ` { "abc": { "defaultValue": { @@ -85,47 +85,47 @@ exports[`defaultPropsHandler ClassDeclaration with static defaultProps should fi "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ClassDeclaration with static defaultProps should find prop default values that are literals 2`] = ` +exports[`defaultPropsHandler > ClassDeclaration with static defaultProps > should find prop default values that are literals 2`] = ` { "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ClassDeclaration with static defaultProps should resolve local spreads 1`] = ` +exports[`defaultPropsHandler > ClassDeclaration with static defaultProps > should resolve local spreads 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ClassExpression with static defaultProps resolves imported values assigned as default props 1`] = ` +exports[`defaultPropsHandler > ClassExpression with static defaultProps > resolves imported values assigned as default props 1`] = ` { "abc": { "defaultValue": { @@ -142,19 +142,19 @@ exports[`defaultPropsHandler ClassExpression with static defaultProps resolves i "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ClassExpression with static defaultProps should find prop default values that are literals 1`] = ` +exports[`defaultPropsHandler > ClassExpression with static defaultProps > should find prop default values that are literals 1`] = ` { "abc": { "defaultValue": { @@ -171,86 +171,86 @@ exports[`defaultPropsHandler ClassExpression with static defaultProps should fin "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler Functional components with default params allows imported defaults to be aliased 1`] = ` +exports[`defaultPropsHandler > Functional components with default params > allows imported defaults to be aliased 1`] = ` { "foo": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, } `; -exports[`defaultPropsHandler Functional components with default params can use imported values as default props 1`] = ` +exports[`defaultPropsHandler > Functional components with default params > can use imported values as default props 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, } `; -exports[`defaultPropsHandler Functional components with default params overrides with imported defaultProps 1`] = ` +exports[`defaultPropsHandler > Functional components with default params > overrides with imported defaultProps 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, }, } `; -exports[`defaultPropsHandler Functional components with default params resolves imported spreads 1`] = ` +exports[`defaultPropsHandler > Functional components with default params > resolves imported spreads 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler Functional components with default params resolves local spreads 1`] = ` +exports[`defaultPropsHandler > Functional components with default params > resolves local spreads 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler Functional components with default params should find default props that are literals 1`] = ` +exports[`defaultPropsHandler > Functional components with default params > should find default props that are literals 1`] = ` { "abc": { "defaultValue": { @@ -267,19 +267,19 @@ exports[`defaultPropsHandler Functional components with default params should fi "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler Functional components with default params should find prop default values that are imported variables 1`] = ` +exports[`defaultPropsHandler > Functional components with default params > should find prop default values that are imported variables 1`] = ` { "foo": { "defaultValue": { @@ -290,7 +290,7 @@ exports[`defaultPropsHandler Functional components with default params should fi } `; -exports[`defaultPropsHandler Functional components with default params should override with defaultProps if available 1`] = ` +exports[`defaultPropsHandler > Functional components with default params > should override with defaultProps if available 1`] = ` { "abc": { "defaultValue": { @@ -307,19 +307,19 @@ exports[`defaultPropsHandler Functional components with default params should ov "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler Functional components with default params should work with aliases 1`] = ` +exports[`defaultPropsHandler > Functional components with default params > should work with aliases 1`] = ` { "abc": { "defaultValue": { @@ -336,21 +336,21 @@ exports[`defaultPropsHandler Functional components with default params should wo "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler Functional components with default params should work with no defaults 1`] = `{}`; +exports[`defaultPropsHandler > Functional components with default params > should work with no defaults 1`] = `{}`; -exports[`defaultPropsHandler ObjectExpression can resolve declared functions 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > can resolve declared functions 1`] = ` { "abc": { "defaultValue": { @@ -367,30 +367,30 @@ exports[`defaultPropsHandler ObjectExpression can resolve declared functions 1`] "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ObjectExpression can resolve object methods 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > can resolve object methods 1`] = ` { "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ObjectExpression handles computed properties 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > handles computed properties 1`] = ` { "@computed#bar": { "defaultValue": { @@ -401,86 +401,86 @@ exports[`defaultPropsHandler ObjectExpression handles computed properties 1`] = "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ObjectExpression handles imported values assigned to computed properties 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > handles imported values assigned to computed properties 1`] = ` { "@computed#bar": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ObjectExpression ignores complex computed properties 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > ignores complex computed properties 1`] = ` { "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ObjectExpression ignores imported values assigned to complex computed properties 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > ignores imported values assigned to complex computed properties 1`] = ` { "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ObjectExpression resolves imported spreads 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > resolves imported spreads 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ObjectExpression resolves local spreads 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > resolves local spreads 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler ObjectExpression should find prop default values that are literals 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > should find prop default values that are literals 1`] = ` { "abc": { "defaultValue": { @@ -497,7 +497,7 @@ exports[`defaultPropsHandler ObjectExpression should find prop default values th "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "bigint": { @@ -515,7 +515,7 @@ exports[`defaultPropsHandler ObjectExpression should find prop default values th "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, "nullliteral": { @@ -539,7 +539,7 @@ exports[`defaultPropsHandler ObjectExpression should find prop default values th } `; -exports[`defaultPropsHandler ObjectExpression should find prop default values that are literals from imported functions 1`] = ` +exports[`defaultPropsHandler > ObjectExpression > should find prop default values that are literals from imported functions 1`] = ` { "abc": { "defaultValue": { @@ -556,19 +556,19 @@ exports[`defaultPropsHandler ObjectExpression should find prop default values th "baz": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, "foo": { "defaultValue": { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, }, } `; -exports[`defaultPropsHandler can have an importer that resolves spread properties 1`] = ` +exports[`defaultPropsHandler > can have an importer that resolves spread properties 1`] = ` { "123": { "defaultValue": { @@ -591,18 +591,18 @@ exports[`defaultPropsHandler can have an importer that resolves spread propertie } `; -exports[`defaultPropsHandler forwardRef also resolves imports when the function is not inline 1`] = ` +exports[`defaultPropsHandler > forwardRef > also resolves imports when the function is not inline 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, } `; -exports[`defaultPropsHandler forwardRef resolves default props in the parameters 1`] = ` +exports[`defaultPropsHandler > forwardRef > resolves default props in the parameters 1`] = ` { "foo": { "defaultValue": { @@ -613,7 +613,7 @@ exports[`defaultPropsHandler forwardRef resolves default props in the parameters } `; -exports[`defaultPropsHandler forwardRef resolves defaultProps 1`] = ` +exports[`defaultPropsHandler > forwardRef > resolves defaultProps 1`] = ` { "foo": { "defaultValue": { @@ -624,29 +624,29 @@ exports[`defaultPropsHandler forwardRef resolves defaultProps 1`] = ` } `; -exports[`defaultPropsHandler forwardRef resolves imported default props in the parameters 1`] = ` +exports[`defaultPropsHandler > forwardRef > resolves imported default props in the parameters 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": "["foo", "bar"]", + "value": "[\\"foo\\", \\"bar\\"]", }, }, } `; -exports[`defaultPropsHandler forwardRef resolves imported defaultProps 1`] = ` +exports[`defaultPropsHandler > forwardRef > resolves imported defaultProps 1`] = ` { "bar": { "defaultValue": { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, }, } `; -exports[`defaultPropsHandler forwardRef resolves when the function is not inline 1`] = ` +exports[`defaultPropsHandler > forwardRef > resolves when the function is not inline 1`] = ` { "foo": { "defaultValue": { @@ -657,7 +657,7 @@ exports[`defaultPropsHandler forwardRef resolves when the function is not inline } `; -exports[`defaultPropsHandler should only consider Property nodes, not e.g. spread properties 1`] = ` +exports[`defaultPropsHandler > should only consider Property nodes, not e.g. spread properties 1`] = ` { "bar": { "defaultValue": { diff --git a/packages/react-docgen/src/handlers/__tests__/__snapshots__/propTypeHandler-test.ts.snap b/packages/react-docgen/src/handlers/__tests__/__snapshots__/propTypeHandler-test.ts.snap index b5d999e92ff..2e32e89e499 100644 --- a/packages/react-docgen/src/handlers/__tests__/__snapshots__/propTypeHandler-test.ts.snap +++ b/packages/react-docgen/src/handlers/__tests__/__snapshots__/propTypeHandler-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`propTypeHandler React.createClass can resolve individual imported variables assigned to props 1`] = ` +exports[`propTypeHandler > React.createClass > can resolve individual imported variables assigned to props 1`] = ` { "@computed#bar": { "required": false, @@ -25,7 +25,7 @@ exports[`propTypeHandler React.createClass can resolve individual imported varia } `; -exports[`propTypeHandler React.createClass handles computed properties 1`] = ` +exports[`propTypeHandler > React.createClass > handles computed properties 1`] = ` { "@computed#foo": { "required": true, @@ -38,7 +38,7 @@ exports[`propTypeHandler React.createClass handles computed properties 1`] = ` } `; -exports[`propTypeHandler React.createClass ignores complex computed properties 1`] = ` +exports[`propTypeHandler > React.createClass > ignores complex computed properties 1`] = ` { "complex_prop": { "required": true, @@ -47,7 +47,37 @@ exports[`propTypeHandler React.createClass ignores complex computed properties 1 } `; -exports[`propTypeHandler class definition class property can resolve individual imported variables assigned to props 1`] = ` +exports[`propTypeHandler > React.createClass > passes the correct argument to getPropType 1`] = ` +Node { + "computed": false, + "object": Node { + "name": "PropTypes", + "type": "Identifier", + }, + "property": Node { + "name": "bool", + "type": "Identifier", + }, + "type": "MemberExpression", +} +`; + +exports[`propTypeHandler > React.createClass > passes the correct argument to getPropType 2`] = ` +Node { + "computed": false, + "object": Node { + "name": "PropTypes", + "type": "Identifier", + }, + "property": Node { + "name": "xyz", + "type": "Identifier", + }, + "type": "MemberExpression", +} +`; + +exports[`propTypeHandler > class definition > class property > can resolve individual imported variables assigned to props 1`] = ` { "@computed#bar": { "required": false, @@ -72,7 +102,7 @@ exports[`propTypeHandler class definition class property can resolve individual } `; -exports[`propTypeHandler class definition class property handles computed properties 1`] = ` +exports[`propTypeHandler > class definition > class property > handles computed properties 1`] = ` { "@computed#foo": { "required": true, @@ -85,7 +115,7 @@ exports[`propTypeHandler class definition class property handles computed proper } `; -exports[`propTypeHandler class definition class property ignores complex computed properties 1`] = ` +exports[`propTypeHandler > class definition > class property > ignores complex computed properties 1`] = ` { "complex_prop": { "required": true, @@ -94,7 +124,37 @@ exports[`propTypeHandler class definition class property ignores complex compute } `; -exports[`propTypeHandler class definition static getter can resolve individual imported variables assigned to props 1`] = ` +exports[`propTypeHandler > class definition > class property > passes the correct argument to getPropType 1`] = ` +Node { + "computed": false, + "object": Node { + "name": "PropTypes", + "type": "Identifier", + }, + "property": Node { + "name": "bool", + "type": "Identifier", + }, + "type": "MemberExpression", +} +`; + +exports[`propTypeHandler > class definition > class property > passes the correct argument to getPropType 2`] = ` +Node { + "computed": false, + "object": Node { + "name": "PropTypes", + "type": "Identifier", + }, + "property": Node { + "name": "xyz", + "type": "Identifier", + }, + "type": "MemberExpression", +} +`; + +exports[`propTypeHandler > class definition > static getter > can resolve individual imported variables assigned to props 1`] = ` { "@computed#bar": { "required": false, @@ -119,7 +179,7 @@ exports[`propTypeHandler class definition static getter can resolve individual i } `; -exports[`propTypeHandler class definition static getter handles computed properties 1`] = ` +exports[`propTypeHandler > class definition > static getter > handles computed properties 1`] = ` { "@computed#foo": { "required": true, @@ -132,7 +192,7 @@ exports[`propTypeHandler class definition static getter handles computed propert } `; -exports[`propTypeHandler class definition static getter ignores complex computed properties 1`] = ` +exports[`propTypeHandler > class definition > static getter > ignores complex computed properties 1`] = ` { "complex_prop": { "required": true, @@ -141,7 +201,37 @@ exports[`propTypeHandler class definition static getter ignores complex computed } `; -exports[`propTypeHandler stateless component can resolve individual imported variables assigned to props 1`] = ` +exports[`propTypeHandler > class definition > static getter > passes the correct argument to getPropType 1`] = ` +Node { + "computed": false, + "object": Node { + "name": "PropTypes", + "type": "Identifier", + }, + "property": Node { + "name": "bool", + "type": "Identifier", + }, + "type": "MemberExpression", +} +`; + +exports[`propTypeHandler > class definition > static getter > passes the correct argument to getPropType 2`] = ` +Node { + "computed": false, + "object": Node { + "name": "PropTypes", + "type": "Identifier", + }, + "property": Node { + "name": "xyz", + "type": "Identifier", + }, + "type": "MemberExpression", +} +`; + +exports[`propTypeHandler > stateless component > can resolve individual imported variables assigned to props 1`] = ` { "@computed#bar": { "required": false, @@ -166,7 +256,7 @@ exports[`propTypeHandler stateless component can resolve individual imported var } `; -exports[`propTypeHandler stateless component handles computed properties 1`] = ` +exports[`propTypeHandler > stateless component > handles computed properties 1`] = ` { "@computed#foo": { "required": true, @@ -179,7 +269,7 @@ exports[`propTypeHandler stateless component handles computed properties 1`] = ` } `; -exports[`propTypeHandler stateless component ignores complex computed properties 1`] = ` +exports[`propTypeHandler > stateless component > ignores complex computed properties 1`] = ` { "complex_prop": { "required": true, @@ -187,3 +277,33 @@ exports[`propTypeHandler stateless component ignores complex computed properties }, } `; + +exports[`propTypeHandler > stateless component > passes the correct argument to getPropType 1`] = ` +Node { + "computed": false, + "object": Node { + "name": "PropTypes", + "type": "Identifier", + }, + "property": Node { + "name": "bool", + "type": "Identifier", + }, + "type": "MemberExpression", +} +`; + +exports[`propTypeHandler > stateless component > passes the correct argument to getPropType 2`] = ` +Node { + "computed": false, + "object": Node { + "name": "PropTypes", + "type": "Identifier", + }, + "property": Node { + "name": "xyz", + "type": "Identifier", + }, + "type": "MemberExpression", +} +`; diff --git a/packages/react-docgen/src/handlers/__tests__/codeTypeHandler-test.ts b/packages/react-docgen/src/handlers/__tests__/codeTypeHandler-test.ts index 524151b5b91..7af2ef47906 100644 --- a/packages/react-docgen/src/handlers/__tests__/codeTypeHandler-test.ts +++ b/packages/react-docgen/src/handlers/__tests__/codeTypeHandler-test.ts @@ -1,6 +1,6 @@ import { parse, makeMockImporter } from '../../../tests/utils'; import Documentation from '../../Documentation'; -import codeTypeHandler from '../codeTypeHandler'; +import codeTypeHandler from '../codeTypeHandler.js'; import type DocumentationMock from '../../__mocks__/Documentation'; import type { ArrowFunctionExpression, @@ -11,9 +11,10 @@ import type { } from '@babel/types'; import type { NodePath } from '@babel/traverse'; import type { ComponentNode } from '../../resolver'; +import { beforeEach, describe, expect, test, vi } from 'vitest'; -jest.mock('../../Documentation'); -jest.mock('../../utils/getFlowType', () => ({ +vi.mock('../../Documentation.js'); +vi.mock('../../utils/getFlowType.js', () => ({ default: () => ({}), __esModule: true, })); @@ -50,8 +51,10 @@ describe('codeTypeHandler', () => { `; } - function test(getSrc: (src: string) => NodePath) { - it('detects types correctly', () => { + function testCodeTypeHandler( + getSrc: (src: string) => NodePath, + ) { + test('detects types correctly', () => { const flowTypesSrc = ` { foo: string, @@ -82,7 +85,7 @@ describe('codeTypeHandler', () => { }); }); - it('detects whether a prop is required', () => { + test('detects whether a prop is required', () => { const flowTypesSrc = ` { foo: string, @@ -107,7 +110,7 @@ describe('codeTypeHandler', () => { }); }); - it('ignores hash map entry', () => { + test('ignores hash map entry', () => { const flowTypesSrc = ` { [key: string]: string, @@ -121,7 +124,7 @@ describe('codeTypeHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('detects union types', () => { + test('detects union types', () => { const flowTypesSrc = ` { foo: string | number, @@ -146,7 +149,7 @@ describe('codeTypeHandler', () => { }); }); - it('detects intersection types', () => { + test('detects intersection types', () => { const flowTypesSrc = ` { foo: Foo & Bar, @@ -167,7 +170,7 @@ describe('codeTypeHandler', () => { describe('special generic type annotations', () => { ['$ReadOnly', '$Exact'].forEach(annotation => { - it(`unwraps ${annotation}<...>`, () => { + test(`unwraps ${annotation}<...>`, () => { const flowTypesSrc = ` ${annotation}<{ foo: string | number, @@ -192,7 +195,7 @@ describe('codeTypeHandler', () => { describe('TypeAlias', () => { describe('class definition for flow <0.53', () => { - test(propTypesSrc => + testCodeTypeHandler(propTypesSrc => parse.statement( template( 'class Foo extends Component {}', @@ -203,7 +206,7 @@ describe('codeTypeHandler', () => { }); describe('class definition for flow >=0.53 without State', () => { - test(propTypesSrc => + testCodeTypeHandler(propTypesSrc => parse.statement( template('class Foo extends Component {}', propTypesSrc), ), @@ -211,7 +214,7 @@ describe('codeTypeHandler', () => { }); describe('class definition for flow >=0.53 with State', () => { - test(propTypesSrc => + testCodeTypeHandler(propTypesSrc => parse.statement( template( 'class Foo extends Component {}', @@ -222,7 +225,7 @@ describe('codeTypeHandler', () => { }); describe('class definition with inline props', () => { - test(propTypesSrc => + testCodeTypeHandler(propTypesSrc => parse.statement( template( 'class Foo extends Component { props: Props; }', @@ -233,7 +236,7 @@ describe('codeTypeHandler', () => { }); describe('stateless component', () => { - test( + testCodeTypeHandler( propTypesSrc => parse .statement(template('(props: Props) =>
;', propTypesSrc)) @@ -243,13 +246,13 @@ describe('codeTypeHandler', () => { }); describe('does not error if flowTypes cannot be found', () => { - it('ObjectExpression', () => { + test('ObjectExpression', () => { const definition = parse.expression('{fooBar: 42}'); expect(() => codeTypeHandler(documentation, definition)).not.toThrow(); }); - it('ClassDeclaration', () => { + test('ClassDeclaration', () => { const definition = parse.statement( 'class Foo extends Component {}', ); @@ -257,7 +260,7 @@ describe('codeTypeHandler', () => { expect(() => codeTypeHandler(documentation, definition)).not.toThrow(); }); - it('ArrowFunctionExpression', () => { + test('ArrowFunctionExpression', () => { const definition = parse.statement('() =>
'); @@ -265,7 +268,7 @@ describe('codeTypeHandler', () => { }); }); - it('supports intersection proptypes', () => { + test('supports intersection proptypes', () => { const definition = parse .statement( `(props: Props) =>
; @@ -286,7 +289,7 @@ describe('codeTypeHandler', () => { }); }); - it('does support utility types inline', () => { + test('does support utility types inline', () => { const definition = parse .statement( `(props: $ReadOnly) =>
; @@ -299,7 +302,7 @@ describe('codeTypeHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('does not support union proptypes', () => { + test('does not support union proptypes', () => { const definition = parse .statement( `(props: Props) =>
; @@ -315,7 +318,7 @@ describe('codeTypeHandler', () => { }); describe('imported prop types', () => { - it('does not resolve type included by require', () => { + test('does not resolve type included by require', () => { const definition = parse .statement( `(props: Props) =>
; @@ -330,7 +333,7 @@ describe('codeTypeHandler', () => { expect(documentation.descriptors).toEqual({}); }); - it('imported', () => { + test('imported', () => { const definition = parse .statement( `(props: Props) =>
; @@ -345,7 +348,7 @@ describe('codeTypeHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('type not imported', () => { + test('type not imported', () => { const definition = parse .statement( `(props: Props) =>
; @@ -359,7 +362,7 @@ describe('codeTypeHandler', () => { expect(documentation.descriptors).toEqual({}); }); - it('type imported', () => { + test('type imported', () => { const definition = parse .statement( `(props: Props) =>
; @@ -374,7 +377,7 @@ describe('codeTypeHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('does not resolve types not in scope', () => { + test('does not resolve types not in scope', () => { const definition = parse .statement( `(props: Props) =>
; @@ -388,7 +391,7 @@ describe('codeTypeHandler', () => { expect(documentation.descriptors).toEqual({}); }); - it('does not resolve types not in scope', () => { + test('does not resolve types not in scope', () => { const definition = parse .statement( `(props: Props) =>
; @@ -404,7 +407,7 @@ describe('codeTypeHandler', () => { }); describe('forwardRef', () => { - it('resolves prop type from function expression', () => { + test('resolves prop type from function expression', () => { const src = ` import React from 'react'; type Props = { foo: string }; @@ -421,7 +424,7 @@ describe('codeTypeHandler', () => { }); }); - it('resolves when the function is not inline', () => { + test('resolves when the function is not inline', () => { const src = ` import React from 'react'; type Props = { foo: string }; @@ -439,7 +442,7 @@ describe('codeTypeHandler', () => { }); }); - it('resolves when the function is rebound and not inline', () => { + test('resolves when the function is rebound and not inline', () => { const src = ` import React from 'react'; type Props = { foo: string }; diff --git a/packages/react-docgen/src/handlers/__tests__/componentDocblockHandler-test.ts b/packages/react-docgen/src/handlers/__tests__/componentDocblockHandler-test.ts index ded44012c65..5fd5b2fdbf9 100644 --- a/packages/react-docgen/src/handlers/__tests__/componentDocblockHandler-test.ts +++ b/packages/react-docgen/src/handlers/__tests__/componentDocblockHandler-test.ts @@ -1,5 +1,5 @@ import { makeMockImporter, parse } from '../../../tests/utils'; -import componentDocblockHandler from '../componentDocblockHandler'; +import componentDocblockHandler from '../componentDocblockHandler.js'; import Documentation from '../../Documentation'; import type DocumentationMock from '../../__mocks__/Documentation'; import type { NodePath } from '@babel/traverse'; @@ -15,8 +15,9 @@ import type { VariableDeclaration, } from '@babel/types'; import type { ComponentNode } from '../../resolver'; +import { beforeEach, describe, expect, test, vi } from 'vitest'; -jest.mock('../../Documentation'); +vi.mock('../../Documentation.js'); describe('componentDocblockHandler', () => { let documentation: Documentation & DocumentationMock; @@ -25,11 +26,11 @@ describe('componentDocblockHandler', () => { documentation = new Documentation() as Documentation & DocumentationMock; }); - function test( + function testDockblockHandler( definitionSrc: string, parseFunc: (src: string) => NodePath, ) { - it('finds docblocks for component definitions', () => { + test('finds docblocks for component definitions', () => { const definition = parseFunc(` import something from 'somewhere'; @@ -43,7 +44,7 @@ describe('componentDocblockHandler', () => { expect(documentation.description).toBe('Component description'); }); - it('ignores other types of comments', () => { + test('ignores other types of comments', () => { let definition = parseFunc(` import something from 'somewhere'; @@ -65,7 +66,7 @@ describe('componentDocblockHandler', () => { expect(documentation.description).toBe(''); }); - it('only considers the docblock directly above the definition', () => { + test('only considers the docblock directly above the definition', () => { const definition = parseFunc(` import something from 'somewhere'; @@ -91,7 +92,7 @@ describe('componentDocblockHandler', () => { exportSrc = '', ) { describe('decorators', () => { - it("uses the docblock above the decorator if it's the only one", () => { + test("uses the docblock above the decorator if it's the only one", () => { const definition = parseFunc(` import something from 'somewhere'; /** @@ -107,7 +108,7 @@ describe('componentDocblockHandler', () => { expect(documentation.description).toBe('Component description'); }); - it('uses the component docblock if present', () => { + test('uses the component docblock if present', () => { const definition = parseFunc(` import something from 'somewhere'; @@ -157,7 +158,7 @@ describe('componentDocblockHandler', () => { }); describe('imports', () => { - it('can use a custom importer to resolve docblocks on imported components', () => { + test('can use a custom importer to resolve docblocks on imported components', () => { const program = parse .statementLast( `import ${importDef} from 'test1'; @@ -171,7 +172,7 @@ describe('componentDocblockHandler', () => { }); }); - it('traverses multiple imports', () => { + test('traverses multiple imports', () => { const program = parse .statementLast( `import ${importDef} from 'test2'; @@ -186,55 +187,75 @@ describe('componentDocblockHandler', () => { } describe('React.createClass', () => { - test('var Component = React.createClass({})', src => - parse - .statementLast(src) - .get('declarations.0.init.arguments.0') as NodePath); + testDockblockHandler( + 'var Component = React.createClass({})', + src => + parse + .statementLast(src) + .get('declarations.0.init.arguments.0') as NodePath, + ); testImports('export var Component = React.createClass({})', 'Component'); }); describe('ClassDeclaration', () => { - test('class Component {}', src => parse.statementLast(src)); + testDockblockHandler('class Component {}', src => parse.statementLast(src)); testDecorators('class Component {}', src => parse.statementLast(src)); testImports('export class Component {}', 'Component'); }); describe('ClassExpression', () => { - test('var Component = class {};', src => - parse - .statementLast(src) - .get('declarations.0.init') as NodePath); + testDockblockHandler( + 'var Component = class {};', + src => + parse + .statementLast(src) + .get('declarations.0.init') as NodePath, + ); testImports('export var Component = class {};', 'Component'); }); describe('Stateless functions', () => { - test('function Component() {}', src => parse.statementLast(src)); + testDockblockHandler('function Component() {}', src => + parse.statementLast(src), + ); testImports('export function Component() {}', 'Component'); - test('var Component = function () {};', src => - parse - .statementLast(src) - .get('declarations.0.init') as NodePath); + testDockblockHandler( + 'var Component = function () {};', + src => + parse + .statementLast(src) + .get('declarations.0.init') as NodePath, + ); testImports('export var Component = function () {};', 'Component'); - test('var Component = () => {}', src => - parse - .statementLast(src) - .get('declarations.0.init') as NodePath); + testDockblockHandler( + 'var Component = () => {}', + src => + parse + .statementLast(src) + .get('declarations.0.init') as NodePath, + ); testImports('export var Component = () => {}', 'Component'); }); describe('ESM default export', () => { describe('Default React.createClass export', () => { - test('export default React.createClass({});', src => - parse - .statementLast(src) - .get('declaration.arguments.0') as NodePath); + testDockblockHandler( + 'export default React.createClass({});', + src => + parse + .statementLast(src) + .get('declaration.arguments.0') as NodePath, + ); }); describe('Default class declaration export', () => { - test('export default class Component {}', src => - parse - .statementLast(src) - .get('declaration') as NodePath); + testDockblockHandler( + 'export default class Component {}', + src => + parse + .statementLast(src) + .get('declaration') as NodePath, + ); testDecorators( 'class Component {}', src => @@ -246,10 +267,13 @@ describe('componentDocblockHandler', () => { }); describe('Default class expression export', () => { - test('export default class {}', src => - parse - .statementLast(src) - .get('declaration') as NodePath); + testDockblockHandler( + 'export default class {}', + src => + parse + .statementLast(src) + .get('declaration') as NodePath, + ); testDecorators( 'class {}', src => @@ -262,43 +286,58 @@ describe('componentDocblockHandler', () => { describe('Default stateless function export', () => { describe('named function', () => { - test('export default function Component() {}', src => - parse - .statementLast(src) - .get('declaration') as NodePath); + testDockblockHandler( + 'export default function Component() {}', + src => + parse + .statementLast(src) + .get('declaration') as NodePath, + ); }); describe('anonymous function', () => { - test('export default function() {}', src => - parse - .statementLast(src) - .get('declaration') as NodePath); + testDockblockHandler( + 'export default function() {}', + src => + parse + .statementLast(src) + .get('declaration') as NodePath, + ); }); describe('arrow function', () => { - test('export default () => {}', src => - parse - .statementLast(src) - .get('declaration') as NodePath); + testDockblockHandler( + 'export default () => {}', + src => + parse + .statementLast(src) + .get('declaration') as NodePath, + ); }); }); }); describe('ESM named export', () => { describe('Named React.createClass export', () => { - test('export var Component = React.createClass({});', src => - parse - .statementLast(src) - .get( - 'declaration.declarations.0.init.arguments.0', - ) as NodePath); + testDockblockHandler( + 'export var Component = React.createClass({});', + src => + parse + .statementLast(src) + .get( + 'declaration.declarations.0.init.arguments.0', + ) as NodePath, + ); }); describe('Named class declaration export', () => { - test('export class Component {}', src => - parse - .statementLast(src) - .get('declaration') as NodePath); + testDockblockHandler( + 'export class Component {}', + src => + parse + .statementLast(src) + .get('declaration') as NodePath, + ); testDecorators( 'class Component {}', src => @@ -311,24 +350,33 @@ describe('componentDocblockHandler', () => { describe('Named stateless function', () => { describe('named function', () => { - test('export function Component() {}', src => - parse - .statementLast(src) - .get('declaration') as NodePath); + testDockblockHandler( + 'export function Component() {}', + src => + parse + .statementLast(src) + .get('declaration') as NodePath, + ); }); describe('anonymous function', () => { - test('export var Component = function() {}', src => - parse - .statementLast(src) - .get('declaration') as NodePath); + testDockblockHandler( + 'export var Component = function() {}', + src => + parse + .statementLast(src) + .get('declaration') as NodePath, + ); }); describe('arrow function', () => { - test('export var Component = () => {}', src => - parse - .statementLast(src) - .get('declaration') as NodePath); + testDockblockHandler( + 'export var Component = () => {}', + src => + parse + .statementLast(src) + .get('declaration') as NodePath, + ); }); }); }); @@ -337,10 +385,15 @@ describe('componentDocblockHandler', () => { const useDefault = true; describe('inline implementation', () => { - test(` + testDockblockHandler( + ` React.forwardRef((props, ref) => {}); - import React from "react";`, src => - parse.statement(src, -2).get('expression') as NodePath); + import React from "react";`, + src => + parse + .statement(src, -2) + .get('expression') as NodePath, + ); testImports( `import React from 'react'; @@ -351,11 +404,16 @@ describe('componentDocblockHandler', () => { }); describe('inline implementation with memo', () => { - test(` + testDockblockHandler( + ` React.memo(React.forwardRef((props, ref) => {})); import React from "react"; - `, src => - parse.statement(src, -2).get('expression') as NodePath); + `, + src => + parse + .statement(src, -2) + .get('expression') as NodePath, + ); testImports( ` @@ -368,12 +426,17 @@ describe('componentDocblockHandler', () => { }); describe('out of line implementation', () => { - test(` + testDockblockHandler( + ` let Component = (props, ref) => {}; React.forwardRef(Component); import React from "react"; - `, src => - parse.statement(src, -2).get('expression') as NodePath); + `, + src => + parse + .statement(src, -2) + .get('expression') as NodePath, + ); testImports( ` diff --git a/packages/react-docgen/src/handlers/__tests__/componentMethodsHandler-test.ts b/packages/react-docgen/src/handlers/__tests__/componentMethodsHandler-test.ts index eb0bc0e7aa0..b0894804ebb 100644 --- a/packages/react-docgen/src/handlers/__tests__/componentMethodsHandler-test.ts +++ b/packages/react-docgen/src/handlers/__tests__/componentMethodsHandler-test.ts @@ -1,5 +1,5 @@ import { parse, makeMockImporter } from '../../../tests/utils'; -import componentMethodsHandler from '../componentMethodsHandler'; +import componentMethodsHandler from '../componentMethodsHandler.js'; import Documentation from '../../Documentation'; import type DocumentationMock from '../../__mocks__/Documentation'; import type { @@ -13,8 +13,9 @@ import type { } from '@babel/types'; import type { NodePath } from '@babel/traverse'; import type { ComponentNode } from '../../resolver'; +import { beforeEach, describe, expect, test, vi } from 'vitest'; -jest.mock('../../Documentation'); +vi.mock('../../Documentation.js'); describe('componentMethodsHandler', () => { let documentation: Documentation & DocumentationMock; @@ -42,7 +43,7 @@ describe('componentMethodsHandler', () => { `).get('declaration'), }); - function test(definition) { + function testMethodsHandler(definition) { componentMethodsHandler(documentation, definition); expect(documentation.methods).toEqual([ { @@ -96,7 +97,7 @@ describe('componentMethodsHandler', () => { Object.entries(methodDefinitions).forEach(([name, code]) => { describe(name, () => { - it('FunctionExpression Component', () => { + test('FunctionExpression Component', () => { const definition = parse.expressionLast( `import { useImperativeHandle } from 'react'; (function () { @@ -111,7 +112,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('FunctionDeclaration Component', () => { + test('FunctionDeclaration Component', () => { const definition = parse.statementLast( `import { useImperativeHandle } from 'react'; function Component() { @@ -126,7 +127,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('ArrowFunctionExpression Component', () => { + test('ArrowFunctionExpression Component', () => { const definition = parse.expressionLast( `import { useImperativeHandle } from 'react'; (() => { @@ -143,7 +144,7 @@ describe('componentMethodsHandler', () => { }); }); - it('AssignmentExpression and useImperativeHandle', () => { + test('AssignmentExpression and useImperativeHandle', () => { const definition = parse .statement( `import { useImperativeHandle } from 'react'; @@ -165,7 +166,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('VariableDeclaration and useImperativeHandle', () => { + test('VariableDeclaration and useImperativeHandle', () => { const definition = parse .statement( `import { useImperativeHandle } from 'react'; @@ -187,7 +188,7 @@ describe('componentMethodsHandler', () => { }); }); - it('extracts the documentation for an ObjectExpression', () => { + test('extracts the documentation for an ObjectExpression', () => { const src = ` { /** @@ -216,10 +217,10 @@ describe('componentMethodsHandler', () => { } `; - test(parse.expression(src)); + testMethodsHandler(parse.expression(src)); }); - it('can resolve an imported method on an ObjectExpression', () => { + test('can resolve an imported method on an ObjectExpression', () => { const src = ` import baz from 'baz'; ({ @@ -249,10 +250,10 @@ describe('componentMethodsHandler', () => { }) `; - test(parse.expressionLast(src, mockImporter)); + testMethodsHandler(parse.expressionLast(src, mockImporter)); }); - it('extracts the documentation for a ClassDeclaration', () => { + test('extracts the documentation for a ClassDeclaration', () => { const src = ` class Test extends React.Component { /** @@ -284,10 +285,10 @@ describe('componentMethodsHandler', () => { } `; - test(parse.statement(src)); + testMethodsHandler(parse.statement(src)); }); - it('can resolve an imported method on a ClassDeclaration', () => { + test('can resolve an imported method on a ClassDeclaration', () => { const src = ` import baz from 'baz'; class Test extends React.Component { @@ -320,10 +321,10 @@ describe('componentMethodsHandler', () => { } `; - test(parse.statementLast(src, mockImporter)); + testMethodsHandler(parse.statementLast(src, mockImporter)); }); - it('should handle and ignore computed methods', () => { + test('should handle and ignore computed methods', () => { const src = ` class Test extends React.Component { /** @@ -355,7 +356,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('resolves imported methods assigned to computed properties', () => { + test('resolves imported methods assigned to computed properties', () => { const src = ` import foo from 'foo'; class Test extends React.Component { @@ -386,7 +387,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('should handle and ignore private properties', () => { + test('should handle and ignore private properties', () => { const src = ` class Test extends React.Component { #privateProperty = () => { @@ -409,7 +410,7 @@ describe('componentMethodsHandler', () => { }); describe('function components', () => { - it('no methods', () => { + test('no methods', () => { const src = ` (props) => {} `; @@ -422,7 +423,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toEqual([]); }); - it('finds static methods on a component in a variable declaration', () => { + test('finds static methods on a component in a variable declaration', () => { const src = ` const Test = (props) => {}; Test.doFoo = () => {}; @@ -439,7 +440,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('resolves imported methods assigned to static properties on a component', () => { + test('resolves imported methods assigned to static properties on a component', () => { const src = ` const Test = (props) => {}; import doFoo from 'doFoo'; @@ -455,7 +456,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('finds static methods on a component in an assignment', () => { + test('finds static methods on a component in an assignment', () => { const src = ` let Test; Test = (props) => {}; @@ -473,7 +474,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('resolves imported methods assigned on a component in an assignment', () => { + test('resolves imported methods assigned on a component in an assignment', () => { const src = ` let Test; Test = (props) => {}; @@ -490,7 +491,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('finds static methods on a function declaration', () => { + test('finds static methods on a function declaration', () => { const src = ` function Test(props) {} Test.doFoo = () => {}; @@ -505,7 +506,7 @@ describe('componentMethodsHandler', () => { expect(documentation.methods).toMatchSnapshot(); }); - it('resolves imported methods on a function declaration', () => { + test('resolves imported methods on a function declaration', () => { const src = ` function Test(props) {} import doFoo from 'doFoo'; diff --git a/packages/react-docgen/src/handlers/__tests__/componentMethodsJsDocHandler-test.ts b/packages/react-docgen/src/handlers/__tests__/componentMethodsJsDocHandler-test.ts index fd88d92f57d..eb644d9b6db 100644 --- a/packages/react-docgen/src/handlers/__tests__/componentMethodsJsDocHandler-test.ts +++ b/packages/react-docgen/src/handlers/__tests__/componentMethodsJsDocHandler-test.ts @@ -2,7 +2,8 @@ import type { NodePath } from '@babel/traverse'; import Documentation from '../../Documentation'; import type { ComponentNode } from '../../resolver'; import type DocumentationMock from '../../__mocks__/Documentation'; -import componentMethodsJsDocHandler from '../componentMethodsJsDocHandler'; +import componentMethodsJsDocHandler from '../componentMethodsJsDocHandler.js'; +import { beforeEach, describe, expect, test } from 'vitest'; describe('componentMethodsJsDocHandler', () => { let documentation: Documentation & DocumentationMock; @@ -11,7 +12,7 @@ describe('componentMethodsJsDocHandler', () => { documentation = new Documentation() as Documentation & DocumentationMock; }); - it('stays the same when no docblock is present', () => { + test('stays the same when no docblock is present', () => { const methods = [ { name: 'foo', @@ -32,7 +33,7 @@ describe('componentMethodsJsDocHandler', () => { expect(documentation.get('methods')).toEqual(methods); }); - it('adds js doc types when no flow types', () => { + test('adds js doc types when no flow types', () => { documentation.set('methods', [ { name: 'foo', @@ -54,7 +55,7 @@ describe('componentMethodsJsDocHandler', () => { expect(documentation.get('methods')).toMatchSnapshot(); }); - it('keeps flow types over js doc types', () => { + test('keeps flow types over js doc types', () => { documentation.set('methods', [ { name: 'foo', @@ -78,7 +79,7 @@ describe('componentMethodsJsDocHandler', () => { expect(documentation.get('methods')).toMatchSnapshot(); }); - it('adds descriptions', () => { + test('adds descriptions', () => { documentation.set('methods', [ { name: 'foo', diff --git a/packages/react-docgen/src/handlers/__tests__/defaultPropsHandler-test.ts b/packages/react-docgen/src/handlers/__tests__/defaultPropsHandler-test.ts index eab08866fd3..580b25505ba 100644 --- a/packages/react-docgen/src/handlers/__tests__/defaultPropsHandler-test.ts +++ b/packages/react-docgen/src/handlers/__tests__/defaultPropsHandler-test.ts @@ -10,9 +10,10 @@ import type { import { parse, makeMockImporter } from '../../../tests/utils'; import Documentation from '../../Documentation'; import type DocumentationMock from '../../__mocks__/Documentation'; -import defaultPropsHandler from '../defaultPropsHandler'; +import defaultPropsHandler from '../defaultPropsHandler.js'; +import { beforeEach, describe, expect, test, vi } from 'vitest'; -jest.mock('../../Documentation'); +vi.mock('../../Documentation.js'); describe('defaultPropsHandler', () => { let documentation: Documentation & DocumentationMock; @@ -57,7 +58,7 @@ describe('defaultPropsHandler', () => { }); describe('ObjectExpression', () => { - it('should find prop default values that are literals', () => { + test('should find prop default values that are literals', () => { const src = ` { getDefaultProps: function() { @@ -83,7 +84,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('can resolve object methods', () => { + test('can resolve object methods', () => { const src = ` { getDefaultProps() { @@ -101,7 +102,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('can resolve declared functions', () => { + test('can resolve declared functions', () => { const src = ` function getDefaultProps() { return { @@ -120,7 +121,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('should find prop default values that are literals from imported functions', () => { + test('should find prop default values that are literals from imported functions', () => { const src = ` import getDefaultProps from 'getDefaultProps'; @@ -136,7 +137,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('handles computed properties', () => { + test('handles computed properties', () => { const src = ` { getDefaultProps: function() { @@ -155,7 +156,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('handles imported values assigned to computed properties', () => { + test('handles imported values assigned to computed properties', () => { const src = ` import baz from 'baz'; ({ @@ -175,7 +176,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('ignores complex computed properties', () => { + test('ignores complex computed properties', () => { const src = ` ({ getDefaultProps: function() { @@ -191,7 +192,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('ignores imported values assigned to complex computed properties', () => { + test('ignores imported values assigned to complex computed properties', () => { const src = ` import baz from 'baz'; ({ @@ -211,7 +212,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves local spreads', () => { + test('resolves local spreads', () => { const src = ` const other = { bar: "foo" }; @@ -229,7 +230,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves imported spreads', () => { + test('resolves imported spreads', () => { const src = ` import other from 'other'; ({ @@ -251,7 +252,7 @@ describe('defaultPropsHandler', () => { }); describe('ClassDeclaration with static defaultProps', () => { - it('should find prop default values that are literals', () => { + test('should find prop default values that are literals', () => { const src = ` class Foo { static defaultProps = { @@ -270,7 +271,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('should find prop default values that are literals', () => { + test('should find prop default values that are literals', () => { const src = ` class Foo { static get defaultProps() { @@ -288,7 +289,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves imported values assigned as default props', () => { + test('resolves imported values assigned as default props', () => { const src = ` import defaultProps from 'defaultProps'; class Foo { @@ -303,7 +304,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('should resolve local spreads', () => { + test('should resolve local spreads', () => { const src = ` const other = { bar: "foo" }; @@ -319,7 +320,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves imported spreads', () => { + test('resolves imported spreads', () => { const src = ` import other from 'other'; class Foo { @@ -337,9 +338,9 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('should find prop default values that are imported variables', () => { + test('should find prop default values that are imported variables', () => { const src = ` - import ImportedComponent from './ImportedComponent'; + import ImportedComponent from './ImportedComponent.js'; class Foo { static defaultProps = { @@ -352,7 +353,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('can resolve default props that are imported given a custom importer', () => { + test('can resolve default props that are imported given a custom importer', () => { const src = ` import baz from 'baz'; @@ -372,7 +373,7 @@ describe('defaultPropsHandler', () => { }); describe('ClassExpression with static defaultProps', () => { - it('should find prop default values that are literals', () => { + test('should find prop default values that are literals', () => { const src = ` var Bar = class { static defaultProps = { @@ -392,7 +393,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves imported values assigned as default props', () => { + test('resolves imported values assigned as default props', () => { const src = ` import defaultProps from 'defaultProps'; var Bar = class { @@ -410,7 +411,7 @@ describe('defaultPropsHandler', () => { }); }); - it('should only consider Property nodes, not e.g. spread properties', () => { + test('should only consider Property nodes, not e.g. spread properties', () => { const src = ` { getDefaultProps: function() { @@ -427,7 +428,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('can have an importer that resolves spread properties', () => { + test('can have an importer that resolves spread properties', () => { const src = ` import Props from 'defaultProps'; ({ @@ -449,7 +450,7 @@ describe('defaultPropsHandler', () => { }); describe('Functional components with default params', () => { - it('should find default props that are literals', () => { + test('should find default props that are literals', () => { const src = ` ({ foo = "bar", @@ -463,7 +464,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('can use imported values as default props', () => { + test('can use imported values as default props', () => { const src = ` import baz from 'baz'; ({ @@ -478,7 +479,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('should override with defaultProps if available', () => { + test('should override with defaultProps if available', () => { const src = ` var Foo = ({ foo = "bar", @@ -498,7 +499,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('overrides with imported defaultProps', () => { + test('overrides with imported defaultProps', () => { const src = ` import other from 'other'; var Foo = ({ @@ -516,7 +517,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves local spreads', () => { + test('resolves local spreads', () => { const src = ` const other = { bar: "foo" }; var Foo = (props) =>
@@ -532,7 +533,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves imported spreads', () => { + test('resolves imported spreads', () => { const src = ` import other from 'other'; var Foo = (props) =>
@@ -548,7 +549,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('should work with aliases', () => { + test('should work with aliases', () => { const src = ` ({ foo = "bar", @@ -565,7 +566,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('allows imported defaults to be aliased', () => { + test('allows imported defaults to be aliased', () => { const src = ` import baz from 'baz'; ({ @@ -580,9 +581,9 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('should find prop default values that are imported variables', () => { + test('should find prop default values that are imported variables', () => { const src = ` - import ImportedComponent from './ImportedComponent'; + import ImportedComponent from './ImportedComponent.js'; ({ foo = ImportedComponent, @@ -596,7 +597,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('should work with no defaults', () => { + test('should work with no defaults', () => { const src = `({ foo }) =>
`; defaultPropsHandler( @@ -608,7 +609,7 @@ describe('defaultPropsHandler', () => { }); describe('forwardRef', () => { - it('resolves default props in the parameters', () => { + test('resolves default props in the parameters', () => { const src = ` import React from 'react'; React.forwardRef(({ foo = 'bar' }, ref) =>
{foo}
); @@ -621,7 +622,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves imported default props in the parameters', () => { + test('resolves imported default props in the parameters', () => { const src = ` import baz from 'baz'; import React from 'react'; @@ -635,7 +636,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves defaultProps', () => { + test('resolves defaultProps', () => { const src = ` import React from 'react'; const Component = React.forwardRef(({ foo }, ref) =>
{foo}
); @@ -651,7 +652,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves imported defaultProps', () => { + test('resolves imported defaultProps', () => { const src = ` import other from 'other'; import React from 'react'; @@ -668,7 +669,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('resolves when the function is not inline', () => { + test('resolves when the function is not inline', () => { const src = ` import React from 'react'; const ComponentImpl = ({ foo = 'bar' }, ref) =>
{foo}
; @@ -682,7 +683,7 @@ describe('defaultPropsHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('also resolves imports when the function is not inline', () => { + test('also resolves imports when the function is not inline', () => { const src = ` import baz from 'baz'; import React from 'react'; diff --git a/packages/react-docgen/src/handlers/__tests__/displayNameHandler-test.ts b/packages/react-docgen/src/handlers/__tests__/displayNameHandler-test.ts index d81394ca6ea..fbe5091b0f3 100644 --- a/packages/react-docgen/src/handlers/__tests__/displayNameHandler-test.ts +++ b/packages/react-docgen/src/handlers/__tests__/displayNameHandler-test.ts @@ -1,6 +1,6 @@ import { parse, makeMockImporter } from '../../../tests/utils'; import Documentation from '../../Documentation'; -import displayNameHandler from '../displayNameHandler'; +import displayNameHandler from '../displayNameHandler.js'; import type DocumentationMock from '../../__mocks__/Documentation'; import type { ArrowFunctionExpression, @@ -12,8 +12,9 @@ import type { VariableDeclaration, } from '@babel/types'; import type { NodePath } from '@babel/traverse'; +import { beforeEach, describe, expect, test, vi } from 'vitest'; -jest.mock('../../Documentation'); +vi.mock('../../Documentation.js'); describe('defaultPropsHandler', () => { let documentation: Documentation & DocumentationMock; @@ -39,7 +40,7 @@ describe('defaultPropsHandler', () => { `).get('declaration'), }); - it('extracts the displayName', () => { + test('extracts the displayName', () => { const definition = parse.expression( '{displayName: "FooBar"}', ); @@ -48,7 +49,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBar'); }); - it('extracts the imported displayName', () => { + test('extracts the imported displayName', () => { const definition = parse.expressionLast( `import foobarbaz from 'foobarbaz'; ({displayName: foobarbaz});`, @@ -59,7 +60,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBarBaz'); }); - it('resolves identifiers', () => { + test('resolves identifiers', () => { const definition = parse.expressionLast( `var name = 'abc'; ({displayName: name})`, @@ -69,7 +70,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('abc'); }); - it('resolves imported identifiers', () => { + test('resolves imported identifiers', () => { const definition = parse.expressionLast( `import foobarbaz from 'foobarbaz'; var name = foobarbaz; @@ -81,7 +82,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBarBaz'); }); - it('can resolve non-literal names with appropriate importer', () => { + test('can resolve non-literal names with appropriate importer', () => { const definition = parse.expressionLast( `import foo from 'foo'; ({displayName: foo.bar});`, @@ -92,7 +93,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('baz'); }); - it('ignores non-literal names', () => { + test('ignores non-literal names', () => { const definition = parse.expression( '{displayName: foo.bar}', ); @@ -102,14 +103,14 @@ describe('defaultPropsHandler', () => { }); describe('ClassDeclaration', () => { - it('considers the class name', () => { + test('considers the class name', () => { const definition = parse.statement(`class Foo {}`); expect(() => displayNameHandler(documentation, definition)).not.toThrow(); expect(documentation.displayName).toBe('Foo'); }); - it('does not crash if no name', () => { + test('does not crash if no name', () => { const definition = parse .statement(`export default class {}`) .get('declaration') as NodePath; @@ -118,7 +119,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBeUndefined(); }); - it('resolves identifiers', () => { + test('resolves identifiers', () => { const definition = parse.statement(` class Foo { static displayName = name; @@ -130,7 +131,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('xyz'); }); - it('resolves imported identifiers', () => { + test('resolves imported identifiers', () => { const definition = parse.statement( ` class Foo { @@ -146,7 +147,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBarBaz'); }); - it('resolves imported displayName', () => { + test('resolves imported displayName', () => { const definition = parse.statement( ` class Foo { @@ -161,7 +162,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBarBaz'); }); - it('ignores non-literal names', () => { + test('ignores non-literal names', () => { const definition = parse.statement(` class Foo { static displayName = foo.bar; @@ -172,7 +173,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBeUndefined(); }); - it('can resolve non-literal names with appropriate importer', () => { + test('can resolve non-literal names with appropriate importer', () => { const definition = parse.statement( ` class Foo { @@ -187,7 +188,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('foo'); }); - it('considers a static displayName class property', () => { + test('considers a static displayName class property', () => { const definition = parse.statement(` class Foo { static displayName = 'foo'; @@ -198,7 +199,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('foo'); }); - it('considers static displayName getter', () => { + test('considers static displayName getter', () => { const definition = parse.statement(` class Foo { static get displayName() { @@ -211,7 +212,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('foo'); }); - it('considers static displayName property with function expression', () => { + test('considers static displayName property with function expression', () => { const definition = parse.statement(` class Foo { static displayName = function() { @@ -224,7 +225,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('foo'); }); - it('considers static displayName property with function declaration', () => { + test('considers static displayName property with function declaration', () => { const definition = parse.statement(` class Foo { static displayName = displayName; @@ -238,7 +239,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('foo'); }); - it('resolves variables in displayName getter', () => { + test('resolves variables in displayName getter', () => { const definition = parse.statement(` class Foo { static get displayName() { @@ -252,7 +253,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('bar'); }); - it('resolves imported Identifier in displayName getter', () => { + test('resolves imported Identifier in displayName getter', () => { const definition = parse.statement( ` class Foo { @@ -269,7 +270,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBarBaz'); }); - it('resolves imported MemberExpression in displayName getter', () => { + test('resolves imported MemberExpression in displayName getter', () => { const definition = parse.statement( ` class Foo { @@ -288,7 +289,7 @@ describe('defaultPropsHandler', () => { }); describe('FunctionDeclaration', () => { - it('considers the function name', () => { + test('considers the function name', () => { const definition = parse.statement('function Foo () {}'); @@ -296,7 +297,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Foo'); }); - it('does not crash if no name', () => { + test('does not crash if no name', () => { const definition = parse .statement(`export default function () {}`) .get('declaration') as NodePath; @@ -305,7 +306,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBeUndefined(); }); - it('considers a static displayName object property', () => { + test('considers a static displayName object property', () => { const definition = parse.statement(` function Foo () {} Foo.displayName = 'Bar'; @@ -315,7 +316,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Bar'); }); - it('resolves variable assigned to displayName object property', () => { + test('resolves variable assigned to displayName object property', () => { const definition = parse.statement(` function Foo () {} Foo.displayName = bar; @@ -326,7 +327,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Bar'); }); - it('resolves imported Identifier assigned to displayName object property', () => { + test('resolves imported Identifier assigned to displayName object property', () => { const definition = parse.statement( ` function Foo () {} @@ -340,7 +341,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBarBaz'); }); - it('resolves imported MemberExpression assigned to displayName object property', () => { + test('resolves imported MemberExpression assigned to displayName object property', () => { const definition = parse.statement( ` function Foo () {} @@ -356,7 +357,7 @@ describe('defaultPropsHandler', () => { }); describe('FunctionExpression', () => { - it('considers the variable name', () => { + test('considers the variable name', () => { const definition = parse .statement('var Foo = function () {};') .get('declarations.0.init') as NodePath; @@ -365,7 +366,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Foo'); }); - it('considers the variable name on assign', () => { + test('considers the variable name on assign', () => { const definition = parse .statement('Foo = function () {};') .get('expression.right') as NodePath; @@ -374,7 +375,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Foo'); }); - it('considers a static displayName object property over variable name', () => { + test('considers a static displayName object property over variable name', () => { const definition = parse .statement( ` @@ -388,7 +389,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Bar'); }); - it('resolves variable assigned to displayName object property over variable name', () => { + test('resolves variable assigned to displayName object property over variable name', () => { const definition = parse .statement( ` @@ -403,7 +404,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Bar'); }); - it('resolves imported Identifier assigned to displayName object property over variable name', () => { + test('resolves imported Identifier assigned to displayName object property over variable name', () => { const definition = parse .statement( ` @@ -419,7 +420,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBarBaz'); }); - it('resolves imported MemberExpression assigned to displayName object property over variable name', () => { + test('resolves imported MemberExpression assigned to displayName object property over variable name', () => { const definition = parse .statement( ` @@ -437,7 +438,7 @@ describe('defaultPropsHandler', () => { }); describe('ArrowFunctionExpression', () => { - it('considers the variable name', () => { + test('considers the variable name', () => { const definition = parse .statement('var Foo = () => {};') .get('declarations.0.init') as NodePath; @@ -446,7 +447,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Foo'); }); - it('considers the variable name even if wrapped', () => { + test('considers the variable name even if wrapped', () => { const definition = parse .statement('var Foo = React.forwardRef(() => {});') .get( @@ -457,7 +458,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Foo'); }); - it('considers the variable name when handling forwardRef', () => { + test('considers the variable name when handling forwardRef', () => { const definition = parse .statement( ` @@ -471,7 +472,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Foo'); }); - it('considers the variable name on assign', () => { + test('considers the variable name on assign', () => { const definition = parse .statement('Foo = () => {};') .get('expression.right') as NodePath; @@ -480,7 +481,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Foo'); }); - it('considers the variable name on assign even if wrapped', () => { + test('considers the variable name on assign even if wrapped', () => { const definition = parse .statement('Foo = React.forwardRef(() => {});') .get( @@ -491,7 +492,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Foo'); }); - it('considers the variable name on assign when handling forwardRef call', () => { + test('considers the variable name on assign when handling forwardRef call', () => { const definition = parse .statement( ` @@ -505,7 +506,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Foo'); }); - it('considers a static displayName object property over variable name', () => { + test('considers a static displayName object property over variable name', () => { const definition = parse .statement( ` @@ -519,7 +520,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Bar'); }); - it('resolves a variable assigned to displayName object property over variable name', () => { + test('resolves a variable assigned to displayName object property over variable name', () => { const definition = parse .statement( ` @@ -534,7 +535,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Bar'); }); - it('resolves imported Identifier assigned to displayName object property over variable name', () => { + test('resolves imported Identifier assigned to displayName object property over variable name', () => { const definition = parse .statement( ` @@ -550,7 +551,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBarBaz'); }); - it('resolves imported MemberExpression assigned to displayName object property over variable name', () => { + test('resolves imported MemberExpression assigned to displayName object property over variable name', () => { const definition = parse .statement( ` @@ -566,7 +567,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('baz'); }); - it('considers a static displayName object property over variable name even if wrapped', () => { + test('considers a static displayName object property over variable name even if wrapped', () => { const definition = parse .statement( ` @@ -582,7 +583,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Bar'); }); - it('resolves a variable assigned to displayName object property over variable name even if wrapped', () => { + test('resolves a variable assigned to displayName object property over variable name even if wrapped', () => { const definition = parse .statement( ` @@ -599,7 +600,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('Bar'); }); - it('resolves imported Identifier assigned to displayName object property over variable name even if wrapped', () => { + test('resolves imported Identifier assigned to displayName object property over variable name even if wrapped', () => { const definition = parse .statement( ` @@ -617,7 +618,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('FooBarBaz'); }); - it('resolves imported MemberExpression assigned to displayName object property over variable name even if wrapped', () => { + test('resolves imported MemberExpression assigned to displayName object property over variable name even if wrapped', () => { const definition = parse .statement( ` @@ -635,7 +636,7 @@ describe('defaultPropsHandler', () => { expect(documentation.displayName).toBe('baz'); }); - it('ignores assignment to non-literal/identifier', () => { + test('ignores assignment to non-literal/identifier', () => { const definition = parse .statement('Foo.Bar = () => {};') .get('expression.right') as NodePath; diff --git a/packages/react-docgen/src/handlers/__tests__/propDocblockHandler-test.ts b/packages/react-docgen/src/handlers/__tests__/propDocblockHandler-test.ts index 8c8ad175834..22e85057b04 100644 --- a/packages/react-docgen/src/handlers/__tests__/propDocblockHandler-test.ts +++ b/packages/react-docgen/src/handlers/__tests__/propDocblockHandler-test.ts @@ -5,9 +5,10 @@ import Documentation from '../../Documentation'; import type { Importer } from '../../importer'; import type { ComponentNode } from '../../resolver'; import type DocumentationMock from '../../__mocks__/Documentation'; -import propDocBlockHandler from '../propDocBlockHandler'; +import propDocBlockHandler from '../propDocBlockHandler.js'; +import { beforeEach, describe, expect, test, vi } from 'vitest'; -jest.mock('../../Documentation'); +vi.mock('../../Documentation.js'); describe('propDocBlockHandler', () => { let documentation: Documentation & DocumentationMock; @@ -28,11 +29,11 @@ describe('propDocBlockHandler', () => { `).get('declaration'), }); - function test( + function testDocBlockHandler( getSrc: (src: string) => string, parseSrc: (src: string, importer?: Importer) => NodePath, ) { - it('finds docblocks for prop types', () => { + test('finds docblocks for prop types', () => { const definition = parseSrc( getSrc( `{ @@ -59,7 +60,7 @@ describe('propDocBlockHandler', () => { }); }); - it('can handle multline comments', () => { + test('can handle multline comments', () => { const definition = parseSrc( getSrc( `{ @@ -83,7 +84,7 @@ describe('propDocBlockHandler', () => { }); }); - it('ignores non-docblock comments', () => { + test('ignores non-docblock comments', () => { const definition = parseSrc( getSrc( `{ @@ -112,7 +113,7 @@ describe('propDocBlockHandler', () => { }); }); - it('only considers the comment with the property below it', () => { + test('only considers the comment with the property below it', () => { const definition = parseSrc( getSrc( `{ @@ -136,7 +137,7 @@ describe('propDocBlockHandler', () => { }); }); - it('understands and ignores the spread operator', () => { + test('understands and ignores the spread operator', () => { const definition = parseSrc( getSrc( `{ @@ -157,7 +158,7 @@ describe('propDocBlockHandler', () => { }); }); - it('resolves variables', () => { + test('resolves variables', () => { const definition = parseSrc(` ${getSrc('Props')} var Props = { @@ -176,7 +177,7 @@ describe('propDocBlockHandler', () => { }); }); - it('resolves imported variables', () => { + test('resolves imported variables', () => { const definition = parseSrc( ` ${getSrc('Props')} @@ -193,7 +194,7 @@ describe('propDocBlockHandler', () => { }); }); - it('resolves imported variables that are spread', () => { + test('resolves imported variables that are spread', () => { const definition = parseSrc( ` ${getSrc('Props')} @@ -222,7 +223,7 @@ describe('propDocBlockHandler', () => { } describe('React.createClass', () => { - test( + testDocBlockHandler( propTypesSrc => `({propTypes: ${propTypesSrc}})`, (src, importer = noopImporter) => parse @@ -233,7 +234,7 @@ describe('propDocBlockHandler', () => { describe('ClassDefinition', () => { describe('class property', () => { - test( + testDocBlockHandler( propTypesSrc => ` class Foo{ static propTypes = ${propTypesSrc}; @@ -244,7 +245,7 @@ describe('propDocBlockHandler', () => { }); describe('static getter', () => { - test( + testDocBlockHandler( propTypesSrc => ` class Foo{ static get propTypes() { @@ -258,7 +259,7 @@ describe('propDocBlockHandler', () => { }); describe('does not error if propTypes cannot be found', () => { - it('ObjectExpression', () => { + test('ObjectExpression', () => { const definition = parse.expression('{fooBar: 42}'); expect(() => @@ -266,7 +267,7 @@ describe('propDocBlockHandler', () => { ).not.toThrow(); }); - it('ClassDeclaration', () => { + test('ClassDeclaration', () => { const definition = parse.statement('class Foo {}'); expect(() => diff --git a/packages/react-docgen/src/handlers/__tests__/propTypeCompositionHandler-test.ts b/packages/react-docgen/src/handlers/__tests__/propTypeCompositionHandler-test.ts index 80ad32a01be..b98028bec8c 100644 --- a/packages/react-docgen/src/handlers/__tests__/propTypeCompositionHandler-test.ts +++ b/packages/react-docgen/src/handlers/__tests__/propTypeCompositionHandler-test.ts @@ -1,14 +1,15 @@ import { parse, makeMockImporter, noopImporter } from '../../../tests/utils'; -import propTypeCompositionHandler from '../propTypeCompositionHandler'; +import propTypeCompositionHandler from '../propTypeCompositionHandler.js'; import Documentation from '../../Documentation'; import type DocumentationMock from '../../__mocks__/Documentation'; import type { NodePath } from '@babel/traverse'; import type { Importer } from '../../importer'; import type { ClassDeclaration, ObjectExpression } from '@babel/types'; import type { ComponentNode } from '../../resolver'; +import { beforeEach, describe, expect, test, vi } from 'vitest'; -jest.mock('../../Documentation'); -jest.mock('../../utils/getPropType', () => () => ({})); +vi.mock('../../Documentation.js'); +vi.mock('../../utils/getPropType.js', () => () => ({})); describe('propTypeCompositionHandler', () => { let documentation: Documentation & DocumentationMock; @@ -35,11 +36,11 @@ describe('propTypeCompositionHandler', () => { `).get('declaration'), }); - function test( + function testCompositionHandler( getSrc: (src: string) => string, parseSrc: (src: string, importer?: Importer) => NodePath, ) { - it('understands assignment from module', () => { + test('understands assignment from module', () => { let definition = parseSrc(` ${getSrc('Foo.propTypes')} var Foo = require("Foo.react"); @@ -58,7 +59,7 @@ describe('propTypeCompositionHandler', () => { expect(documentation.composes).toEqual(['SharedProps']); }); - it('understands the spread operator', () => { + test('understands the spread operator', () => { const definitionSrc = getSrc( `{ ...Foo.propTypes, @@ -75,7 +76,7 @@ describe('propTypeCompositionHandler', () => { expect(documentation.composes).toEqual(['Foo.react', 'SharedProps']); }); - it('does not add any composes if spreads can be fully resolved with the importer', () => { + test('does not add any composes if spreads can be fully resolved with the importer', () => { const definitionSrc = getSrc( `{ ...Foo.propTypes, @@ -95,7 +96,7 @@ describe('propTypeCompositionHandler', () => { expect(documentation.composes).toEqual([]); }); - it('still adds a composes if the importer cannot resolve a value', () => { + test('still adds a composes if the importer cannot resolve a value', () => { const definitionSrc = getSrc( `{ ...Foo.propTypes, @@ -117,7 +118,7 @@ describe('propTypeCompositionHandler', () => { } describe('React.createClass', () => { - test( + testCompositionHandler( propTypesSrc => `({propTypes: ${propTypesSrc}})`, (src, importer = noopImporter) => parse @@ -128,7 +129,7 @@ describe('propTypeCompositionHandler', () => { describe('class definition', () => { describe('class properties', () => { - test( + testCompositionHandler( propTypesSrc => ` class Component { static propTypes = ${propTypesSrc}; @@ -139,7 +140,7 @@ describe('propTypeCompositionHandler', () => { }); describe('static getter', () => { - test( + testCompositionHandler( propTypesSrc => ` class Component { static get propTypes() { @@ -153,7 +154,7 @@ describe('propTypeCompositionHandler', () => { }); describe('does not error if propTypes cannot be found', () => { - it('ObjectExpression', () => { + test('ObjectExpression', () => { const definition = parse.expression('{fooBar: 42}'); expect(() => @@ -161,7 +162,7 @@ describe('propTypeCompositionHandler', () => { ).not.toThrow(); }); - it('ClassDeclaration', () => { + test('ClassDeclaration', () => { const definition = parse.statement('class Foo {}'); expect(() => diff --git a/packages/react-docgen/src/handlers/__tests__/propTypeHandler-test.ts b/packages/react-docgen/src/handlers/__tests__/propTypeHandler-test.ts index b4e41438fb6..77600bc6524 100644 --- a/packages/react-docgen/src/handlers/__tests__/propTypeHandler-test.ts +++ b/packages/react-docgen/src/handlers/__tests__/propTypeHandler-test.ts @@ -1,7 +1,7 @@ import { parse, makeMockImporter, noopImporter } from '../../../tests/utils'; import Documentation from '../../Documentation'; import type DocumentationMock from '../../__mocks__/Documentation'; -import { propTypeHandler } from '../propTypeHandler'; +import { propTypeHandler } from '../propTypeHandler.js'; import getPropType from '../../utils/getPropType'; import type { NodePath } from '@babel/traverse'; import type { Importer } from '../../importer'; @@ -12,11 +12,12 @@ import type { ObjectExpression, } from '@babel/types'; import type { ComponentNode } from '../../resolver'; +import { beforeEach, describe, expect, test, vi } from 'vitest'; -const getPropTypeMock = getPropType as jest.Mock; +const getPropTypeMock = vi.mocked(getPropType); -jest.mock('../../Documentation'); -jest.mock('../../utils/getPropType', () => jest.fn(() => ({}))); +vi.mock('../../Documentation.js'); +vi.mock('../../utils/getPropType.js', () => ({ default: vi.fn(() => ({})) })); describe('propTypeHandler', () => { let documentation: Documentation & DocumentationMock; @@ -73,28 +74,24 @@ describe('propTypeHandler', () => { `; } - function test( + function testPropTypes( getSrc: (src: string) => string, parseSrc: (src: string, importer?: Importer) => NodePath, ) { - it('passes the correct argument to getPropType', () => { + test('passes the correct argument to getPropType', () => { const propTypesSrc = `{ foo: PropTypes.bool, abc: PropTypes.xyz, }`; const definition = parseSrc(getSrc(propTypesSrc)); - const propTypesAST = parse.expression(propTypesSrc); - - const fooPath = propTypesAST.get('properties.0.value') as NodePath; - const xyzPath = propTypesAST.get('properties.1.value') as NodePath; propTypeHandler(documentation, definition); - expect(getPropTypeMock.mock.calls[0][0]).toEqualASTNode(fooPath); - expect(getPropTypeMock.mock.calls[1][0]).toEqualASTNode(xyzPath); + expect(getPropTypeMock.mock.calls[0][0]).toMatchSnapshot(); + expect(getPropTypeMock.mock.calls[1][0]).toMatchSnapshot(); }); - it('finds definitions via React.PropTypes', () => { + test('finds definitions via React.PropTypes', () => { const definition = parseSrc( getSrc( `{ @@ -122,7 +119,7 @@ describe('propTypeHandler', () => { }); }); - it('finds definitions via the ReactPropTypes module', () => { + test('finds definitions via the ReactPropTypes module', () => { const definition = parseSrc( getSrc( `{ @@ -140,7 +137,7 @@ describe('propTypeHandler', () => { }); }); - it('detects whether a prop is required', () => { + test('detects whether a prop is required', () => { const definition = parseSrc( getSrc( `{ @@ -164,7 +161,7 @@ describe('propTypeHandler', () => { }); }); - it('handles computed properties', () => { + test('handles computed properties', () => { const definition = parseSrc( getSrc( `{ @@ -179,7 +176,7 @@ describe('propTypeHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('ignores complex computed properties', () => { + test('ignores complex computed properties', () => { const definition = parseSrc( getSrc( `{ @@ -194,7 +191,7 @@ describe('propTypeHandler', () => { expect(documentation.descriptors).toMatchSnapshot(); }); - it('only considers definitions from React or ReactPropTypes', () => { + test('only considers definitions from React or ReactPropTypes', () => { const definition = parseSrc( getSrc( `{ @@ -220,7 +217,7 @@ describe('propTypeHandler', () => { }); }); - it('resolves variables', () => { + test('resolves variables', () => { const definitionSrc = getSrc('props'); const definition = parseSrc(` ${definitionSrc} @@ -236,7 +233,7 @@ describe('propTypeHandler', () => { }); }); - it('resolves imported variables', () => { + test('resolves imported variables', () => { const definitionSrc = getSrc('props'); const definition = parseSrc( ` @@ -255,7 +252,7 @@ describe('propTypeHandler', () => { }); }); - it('can resolve individual imported variables assigned to props', () => { + test('can resolve individual imported variables assigned to props', () => { const definitionSrc = getSrc(`{ foo: foo, [bar]: bar, @@ -281,7 +278,7 @@ describe('propTypeHandler', () => { } describe('React.createClass', () => { - test( + testPropTypes( propTypesSrc => template(`({propTypes: ${propTypesSrc}})`), (src, importer = noopImporter) => parse @@ -292,7 +289,7 @@ describe('propTypeHandler', () => { describe('class definition', () => { describe('class property', () => { - test( + testPropTypes( propTypesSrc => template(` class Component { @@ -304,7 +301,7 @@ describe('propTypeHandler', () => { }); describe('static getter', () => { - test( + testPropTypes( propTypesSrc => template(` class Component { @@ -319,7 +316,7 @@ describe('propTypeHandler', () => { }); describe('stateless component', () => { - test( + testPropTypes( propTypesSrc => template(` var Component = (props) =>
; @@ -330,26 +327,26 @@ describe('propTypeHandler', () => { }); describe('does not error if propTypes cannot be found', () => { - it('ObjectExpression', () => { + test('ObjectExpression', () => { const definition = parse.expression('{fooBar: 42}'); expect(() => propTypeHandler(documentation, definition)).not.toThrow(); }); - it('ClassDeclaration', () => { + test('ClassDeclaration', () => { const definition = parse.statement('class Foo {}'); expect(() => propTypeHandler(documentation, definition)).not.toThrow(); }); - it('FunctionDeclaration', () => { + test('FunctionDeclaration', () => { const definition = parse.statement('function Foo() {}'); expect(() => propTypeHandler(documentation, definition)).not.toThrow(); }); - it('ArrowFunctionExpression', () => { + test('ArrowFunctionExpression', () => { const definition = parse.expression('() => {}'); expect(() => propTypeHandler(documentation, definition)).not.toThrow(); @@ -357,7 +354,7 @@ describe('propTypeHandler', () => { }); // This case is handled by propTypeCompositionHandler - it('does not error if propTypes is a member expression', () => { + test('does not error if propTypes is a member expression', () => { const definition = parse.expression( '{propTypes: Foo.propTypes}', ); diff --git a/packages/react-docgen/src/handlers/codeTypeHandler.ts b/packages/react-docgen/src/handlers/codeTypeHandler.ts index 1f32f65b80b..bc3871fc4ae 100644 --- a/packages/react-docgen/src/handlers/codeTypeHandler.ts +++ b/packages/react-docgen/src/handlers/codeTypeHandler.ts @@ -1,18 +1,18 @@ -import type Documentation from '../Documentation'; -import { unwrapUtilityType } from '../utils/flowUtilityTypes'; -import getFlowType from '../utils/getFlowType'; +import type Documentation from '../Documentation.js'; +import { unwrapUtilityType } from '../utils/flowUtilityTypes.js'; +import getFlowType from '../utils/getFlowType.js'; import getTypeFromReactComponent, { applyToTypeProperties, -} from '../utils/getTypeFromReactComponent'; -import getPropertyName from '../utils/getPropertyName'; -import getTSType from '../utils/getTSType'; -import type { TypeParameters } from '../utils/getTypeParameters'; -import resolveToValue from '../utils/resolveToValue'; -import setPropDescription from '../utils/setPropDescription'; +} from '../utils/getTypeFromReactComponent.js'; +import getPropertyName from '../utils/getPropertyName.js'; +import getTSType from '../utils/getTSType.js'; +import type { TypeParameters } from '../utils/getTypeParameters.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import setPropDescription from '../utils/setPropDescription.js'; import type { NodePath } from '@babel/traverse'; import type { FlowType } from '@babel/types'; -import type { ComponentNode } from '../resolver'; -import type { Handler } from '.'; +import type { ComponentNode } from '../resolver/index.js'; +import type { Handler } from './index.js'; function setPropDescriptor( documentation: Documentation, diff --git a/packages/react-docgen/src/handlers/componentDocblockHandler.ts b/packages/react-docgen/src/handlers/componentDocblockHandler.ts index 4d799162747..d4e0a6c50c1 100644 --- a/packages/react-docgen/src/handlers/componentDocblockHandler.ts +++ b/packages/react-docgen/src/handlers/componentDocblockHandler.ts @@ -1,10 +1,10 @@ -import type Documentation from '../Documentation'; -import { getDocblock } from '../utils/docblock'; -import isReactForwardRefCall from '../utils/isReactForwardRefCall'; -import resolveToValue from '../utils/resolveToValue'; +import type Documentation from '../Documentation.js'; +import { getDocblock } from '../utils/docblock.js'; +import isReactForwardRefCall from '../utils/isReactForwardRefCall.js'; +import resolveToValue from '../utils/resolveToValue.js'; import type { NodePath, Node } from '@babel/traverse'; -import type { ComponentNode } from '../resolver'; -import type { Handler } from '.'; +import type { ComponentNode } from '../resolver/index.js'; +import type { Handler } from './index.js'; function getDocblockFromComponent(path: NodePath): string | null { let description: string | null = null; diff --git a/packages/react-docgen/src/handlers/componentMethodsHandler.ts b/packages/react-docgen/src/handlers/componentMethodsHandler.ts index 945ef3022a0..947556ca83a 100644 --- a/packages/react-docgen/src/handlers/componentMethodsHandler.ts +++ b/packages/react-docgen/src/handlers/componentMethodsHandler.ts @@ -1,11 +1,11 @@ -import getMemberValuePath from '../utils/getMemberValuePath'; -import type { MethodNodePath } from '../utils/getMethodDocumentation'; -import getMethodDocumentation from '../utils/getMethodDocumentation'; -import isReactComponentClass from '../utils/isReactComponentClass'; -import isReactComponentMethod from '../utils/isReactComponentMethod'; -import type Documentation from '../Documentation'; -import { shallowIgnoreVisitors } from '../utils/traverse'; -import resolveToValue from '../utils/resolveToValue'; +import getMemberValuePath from '../utils/getMemberValuePath.js'; +import type { MethodNodePath } from '../utils/getMethodDocumentation.js'; +import getMethodDocumentation from '../utils/getMethodDocumentation.js'; +import isReactComponentClass from '../utils/isReactComponentClass.js'; +import isReactComponentMethod from '../utils/isReactComponentMethod.js'; +import type Documentation from '../Documentation.js'; +import { shallowIgnoreVisitors } from '../utils/traverse.js'; +import resolveToValue from '../utils/resolveToValue.js'; import type { NodePath, Scope } from '@babel/traverse'; import { visitors } from '@babel/traverse'; import type { @@ -14,14 +14,14 @@ import type { Identifier, ObjectExpression, } from '@babel/types'; -import type { ComponentNode } from '../resolver'; -import type { Handler } from '.'; +import type { ComponentNode } from '../resolver/index.js'; +import type { Handler } from './index.js'; import { isReactBuiltinCall, isReactForwardRefCall, isStatelessComponent, -} from '../utils'; -import findFunctionReturn from '../utils/findFunctionReturn'; + findFunctionReturn, +} from '../utils/index.js'; /** * The following values/constructs are considered methods: diff --git a/packages/react-docgen/src/handlers/componentMethodsJsDocHandler.ts b/packages/react-docgen/src/handlers/componentMethodsJsDocHandler.ts index a1d672547cc..92c9595794d 100644 --- a/packages/react-docgen/src/handlers/componentMethodsJsDocHandler.ts +++ b/packages/react-docgen/src/handlers/componentMethodsJsDocHandler.ts @@ -1,9 +1,9 @@ -import parseJsDoc from '../utils/parseJsDoc'; +import parseJsDoc from '../utils/parseJsDoc.js'; import type { default as Documentation, MethodDescriptor, -} from '../Documentation'; -import type { Handler } from '.'; +} from '../Documentation.js'; +import type { Handler } from './index.js'; // Merges two objects ignoring null/undefined. function merge(obj1: T, obj2: U): (T & U) | null { diff --git a/packages/react-docgen/src/handlers/defaultPropsHandler.ts b/packages/react-docgen/src/handlers/defaultPropsHandler.ts index fa59ce2a4d3..60c9dfb2567 100644 --- a/packages/react-docgen/src/handlers/defaultPropsHandler.ts +++ b/packages/react-docgen/src/handlers/defaultPropsHandler.ts @@ -1,12 +1,12 @@ -import getPropertyName from '../utils/getPropertyName'; -import getMemberValuePath from '../utils/getMemberValuePath'; -import printValue from '../utils/printValue'; -import resolveToValue from '../utils/resolveToValue'; -import resolveFunctionDefinitionToReturnValue from '../utils/resolveFunctionDefinitionToReturnValue'; -import isReactComponentClass from '../utils/isReactComponentClass'; -import isReactForwardRefCall from '../utils/isReactForwardRefCall'; -import type Documentation from '../Documentation'; -import type { DefaultValueDescriptor } from '../Documentation'; +import getPropertyName from '../utils/getPropertyName.js'; +import getMemberValuePath from '../utils/getMemberValuePath.js'; +import printValue from '../utils/printValue.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import resolveFunctionDefinitionToReturnValue from '../utils/resolveFunctionDefinitionToReturnValue.js'; +import isReactComponentClass from '../utils/isReactComponentClass.js'; +import isReactForwardRefCall from '../utils/isReactForwardRefCall.js'; +import type Documentation from '../Documentation.js'; +import type { DefaultValueDescriptor } from '../Documentation.js'; import type { NodePath } from '@babel/traverse'; import type { Node, @@ -15,8 +15,8 @@ import type { RestElement, SpreadElement, } from '@babel/types'; -import type { ComponentNode } from '../resolver'; -import type { Handler } from '.'; +import type { ComponentNode } from '../resolver/index.js'; +import type { Handler } from './index.js'; function getDefaultValue(path: NodePath): DefaultValueDescriptor | null { let defaultValue: string | undefined; diff --git a/packages/react-docgen/src/handlers/displayNameHandler.ts b/packages/react-docgen/src/handlers/displayNameHandler.ts index 6f18572a722..09501b80eba 100644 --- a/packages/react-docgen/src/handlers/displayNameHandler.ts +++ b/packages/react-docgen/src/handlers/displayNameHandler.ts @@ -1,13 +1,13 @@ -import getMemberValuePath from '../utils/getMemberValuePath'; -import getNameOrValue from '../utils/getNameOrValue'; -import isReactForwardRefCall from '../utils/isReactForwardRefCall'; -import resolveToValue from '../utils/resolveToValue'; -import resolveFunctionDefinitionToReturnValue from '../utils/resolveFunctionDefinitionToReturnValue'; -import type Documentation from '../Documentation'; +import getMemberValuePath from '../utils/getMemberValuePath.js'; +import getNameOrValue from '../utils/getNameOrValue.js'; +import isReactForwardRefCall from '../utils/isReactForwardRefCall.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import resolveFunctionDefinitionToReturnValue from '../utils/resolveFunctionDefinitionToReturnValue.js'; +import type Documentation from '../Documentation.js'; import type { NodePath } from '@babel/traverse'; import type { Identifier } from '@babel/types'; -import type { Handler } from '.'; -import type { ComponentNode } from '../resolver'; +import type { Handler } from './index.js'; +import type { ComponentNode } from '../resolver/index.js'; const displayNameHandler: Handler = function ( documentation: Documentation, diff --git a/packages/react-docgen/src/handlers/index.ts b/packages/react-docgen/src/handlers/index.ts index 7f64d701389..80ab74cc0a2 100644 --- a/packages/react-docgen/src/handlers/index.ts +++ b/packages/react-docgen/src/handlers/index.ts @@ -1,20 +1,20 @@ import type { NodePath } from '@babel/traverse'; -import type Documentation from '../Documentation'; -import type { ComponentNode } from '../resolver'; +import type Documentation from '../Documentation.js'; +import type { ComponentNode } from '../resolver/index.js'; -export { default as componentDocblockHandler } from './componentDocblockHandler'; -export { default as componentMethodsHandler } from './componentMethodsHandler'; -export { default as componentMethodsJsDocHandler } from './componentMethodsJsDocHandler'; -export { default as defaultPropsHandler } from './defaultPropsHandler'; -export { default as displayNameHandler } from './displayNameHandler'; -export { default as codeTypeHandler } from './codeTypeHandler'; -export { default as propDocBlockHandler } from './propDocBlockHandler'; -export { default as propTypeCompositionHandler } from './propTypeCompositionHandler'; +export { default as componentDocblockHandler } from './componentDocblockHandler.js'; +export { default as componentMethodsHandler } from './componentMethodsHandler.js'; +export { default as componentMethodsJsDocHandler } from './componentMethodsJsDocHandler.js'; +export { default as defaultPropsHandler } from './defaultPropsHandler.js'; +export { default as displayNameHandler } from './displayNameHandler.js'; +export { default as codeTypeHandler } from './codeTypeHandler.js'; +export { default as propDocBlockHandler } from './propDocBlockHandler.js'; +export { default as propTypeCompositionHandler } from './propTypeCompositionHandler.js'; export { propTypeHandler, contextTypeHandler, childContextTypeHandler, -} from './propTypeHandler'; +} from './propTypeHandler.js'; export type Handler = ( documentation: Documentation, diff --git a/packages/react-docgen/src/handlers/propDocBlockHandler.ts b/packages/react-docgen/src/handlers/propDocBlockHandler.ts index 05c8ac9b418..04ff4b218c0 100644 --- a/packages/react-docgen/src/handlers/propDocBlockHandler.ts +++ b/packages/react-docgen/src/handlers/propDocBlockHandler.ts @@ -1,11 +1,11 @@ import type { NodePath } from '@babel/traverse'; import type { Node } from '@babel/types'; -import getMemberValuePath from '../utils/getMemberValuePath'; -import resolveToValue from '../utils/resolveToValue'; -import setPropDescription from '../utils/setPropDescription'; -import type Documentation from '../Documentation'; -import type { ComponentNode } from '../resolver'; -import type { Handler } from '.'; +import getMemberValuePath from '../utils/getMemberValuePath.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import setPropDescription from '../utils/setPropDescription.js'; +import type Documentation from '../Documentation.js'; +import type { ComponentNode } from '../resolver/index.js'; +import type { Handler } from './index.js'; function resolveDocumentation( documentation: Documentation, diff --git a/packages/react-docgen/src/handlers/propTypeCompositionHandler.ts b/packages/react-docgen/src/handlers/propTypeCompositionHandler.ts index 7c5aeb20910..1c5aef1632a 100644 --- a/packages/react-docgen/src/handlers/propTypeCompositionHandler.ts +++ b/packages/react-docgen/src/handlers/propTypeCompositionHandler.ts @@ -1,11 +1,11 @@ -import getMemberValuePath from '../utils/getMemberValuePath'; -import resolveToModule from '../utils/resolveToModule'; -import resolveToValue from '../utils/resolveToValue'; -import type Documentation from '../Documentation'; +import getMemberValuePath from '../utils/getMemberValuePath.js'; +import resolveToModule from '../utils/resolveToModule.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import type Documentation from '../Documentation.js'; import type { NodePath } from '@babel/traverse'; import type { ObjectExpression, Node } from '@babel/types'; -import type { Handler } from '.'; -import type { ComponentNode } from '../resolver'; +import type { Handler } from './index.js'; +import type { ComponentNode } from '../resolver/index.js'; /** * It resolves the path to its module name and adds it to the "composes" entry diff --git a/packages/react-docgen/src/handlers/propTypeHandler.ts b/packages/react-docgen/src/handlers/propTypeHandler.ts index 122189ab23f..f92c2c89eee 100644 --- a/packages/react-docgen/src/handlers/propTypeHandler.ts +++ b/packages/react-docgen/src/handlers/propTypeHandler.ts @@ -1,17 +1,17 @@ -import getPropType from '../utils/getPropType'; -import getPropertyName from '../utils/getPropertyName'; -import getMemberValuePath from '../utils/getMemberValuePath'; -import isReactModuleName from '../utils/isReactModuleName'; -import isRequiredPropType from '../utils/isRequiredPropType'; -import printValue from '../utils/printValue'; -import resolveToModule from '../utils/resolveToModule'; -import resolveToValue from '../utils/resolveToValue'; -import type Documentation from '../Documentation'; -import type { PropDescriptor, PropTypeDescriptor } from '../Documentation'; +import getPropType from '../utils/getPropType.js'; +import getPropertyName from '../utils/getPropertyName.js'; +import getMemberValuePath from '../utils/getMemberValuePath.js'; +import isReactModuleName from '../utils/isReactModuleName.js'; +import isRequiredPropType from '../utils/isRequiredPropType.js'; +import printValue from '../utils/printValue.js'; +import resolveToModule from '../utils/resolveToModule.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import type Documentation from '../Documentation.js'; +import type { PropDescriptor, PropTypeDescriptor } from '../Documentation.js'; import type { NodePath } from '@babel/traverse'; import type { Node } from '@babel/types'; -import type { Handler } from '.'; -import type { ComponentNode } from '../resolver'; +import type { Handler } from './index.js'; +import type { ComponentNode } from '../resolver/index.js'; function isPropTypesExpression(path: NodePath): boolean { const moduleName = resolveToModule(path); diff --git a/packages/react-docgen/src/importer/fsImporter.ts b/packages/react-docgen/src/importer/fsImporter.ts index 29dc755fd86..ceb9a46df96 100644 --- a/packages/react-docgen/src/importer/fsImporter.ts +++ b/packages/react-docgen/src/importer/fsImporter.ts @@ -1,221 +1,4 @@ -import { shallowIgnoreVisitors } from '../utils/traverse'; -import resolve from 'resolve'; -import { dirname } from 'path'; -import fs from 'fs'; -import type { NodePath } from '@babel/traverse'; -import { visitors } from '@babel/traverse'; -import type { ExportSpecifier, Identifier, ObjectProperty } from '@babel/types'; -import type { Importer, ImportPath } from '.'; -import type FileState from '../FileState'; -import { resolveObjectPatternPropertyToValue } from '../utils'; - -function defaultLookupModule(filename: string, basedir: string): string { - return resolve.sync(filename, { - basedir, - extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx'], - }); -} - -interface TraverseState { - readonly name: string; - readonly file: FileState; - readonly seen: Set; - resultPath?: NodePath | null; -} - -// Factory for the resolveImports importer -export function makeFsImporter( - lookupModule: ( - filename: string, - basedir: string, - ) => string = defaultLookupModule, - cache: Map = new Map(), -): Importer { - function resolveImportedValue( - path: ImportPath, - name: string, - file: FileState, - seen: Set = new Set(), - ): NodePath | null { - // Bail if no filename was provided for the current source file. - // Also never traverse into react itself. - const source = path.node.source?.value; - const { filename } = file.opts; - - if (!source || !filename || source === 'react') { - return null; - } - - // Resolve the imported module using the Node resolver - const basedir = dirname(filename); - let resolvedSource: string | undefined; - - try { - resolvedSource = lookupModule(source, basedir); - } catch (err) { - return null; - } - - // Prevent recursive imports - if (seen.has(resolvedSource)) { - return null; - } - - seen.add(resolvedSource); - - let nextFile = cache.get(resolvedSource); - - if (!nextFile) { - // Read and parse the code - const src = fs.readFileSync(resolvedSource, 'utf8'); - - nextFile = file.parse(src, resolvedSource); - - cache.set(resolvedSource, nextFile); - } - - return findExportedValue(nextFile, name, seen); - } - - const explodedVisitors = visitors.explode({ - ...shallowIgnoreVisitors, - ExportNamedDeclaration: { - enter: function (path, state) { - const { file, name, seen } = state; - const declaration = path.get('declaration'); - - // export const/var ... - if (declaration.hasNode() && declaration.isVariableDeclaration()) { - for (const declPath of declaration.get('declarations')) { - const id = declPath.get('id'); - const init = declPath.get('init'); - - if (id.isIdentifier() && id.node.name === name && init.hasNode()) { - // export const/var a = - - state.resultPath = init; - - break; - } else if (id.isObjectPattern()) { - // export const/var { a } = - - state.resultPath = id.get('properties').find(prop => { - if (prop.isObjectProperty()) { - const value = prop.get('value'); - - return value.isIdentifier() && value.node.name === name; - } - // We don't handle RestElement here yet as complicated - - return false; - }); - - if (state.resultPath) { - state.resultPath = resolveObjectPatternPropertyToValue( - state.resultPath as NodePath, - ); - - break; - } - } - // ArrayPattern not handled yet - } - } else if ( - declaration.hasNode() && - declaration.has('id') && - (declaration.get('id') as NodePath).isIdentifier() && - (declaration.get('id') as NodePath).node.name === name - ) { - // export function/class/type/interface/enum ... - - state.resultPath = declaration; - } else if (path.has('specifiers')) { - // export { ... } or export x from ... or export * as x from ... - - for (const specifierPath of path.get('specifiers')) { - if (specifierPath.isExportNamespaceSpecifier()) { - continue; - } - const exported = specifierPath.get('exported'); - - if (exported.isIdentifier() && exported.node.name === name) { - // export ... from '' - if (path.has('source')) { - const local = specifierPath.isExportSpecifier() - ? specifierPath.node.local.name - : 'default'; - - state.resultPath = resolveImportedValue( - path, - local, - file, - seen, - ); - if (state.resultPath) { - break; - } - } else { - state.resultPath = ( - specifierPath as NodePath - ).get('local'); - - break; - } - } - } - } - - state.resultPath ? path.stop() : path.skip(); - }, - }, - ExportDefaultDeclaration: { - enter: function (path, state) { - const { name } = state; - - if (name === 'default') { - state.resultPath = path.get('declaration'); - - return path.stop(); - } - - path.skip(); - }, - }, - ExportAllDeclaration: { - enter: function (path, state) { - const { name, file, seen } = state; - const resolvedPath = resolveImportedValue(path, name, file, seen); - - if (resolvedPath) { - state.resultPath = resolvedPath; - - return path.stop(); - } - - path.skip(); - }, - }, - }); - - // Traverses the program looking for an export that matches the requested name - function findExportedValue( - file: FileState, - name: string, - seen: Set, - ): NodePath | null { - const state: TraverseState = { - file, - name, - seen, - }; - - file.traverse(explodedVisitors, state); - - return state.resultPath || null; - } - - return resolveImportedValue; -} +import makeFsImporter from './makeFsImporter.js'; const defaultFsImporter = makeFsImporter(); diff --git a/packages/react-docgen/src/importer/ignoreImports.ts b/packages/react-docgen/src/importer/ignoreImports.ts index 7d44ece037b..c8adfee9bbb 100644 --- a/packages/react-docgen/src/importer/ignoreImports.ts +++ b/packages/react-docgen/src/importer/ignoreImports.ts @@ -1,4 +1,4 @@ -import type { Importer } from '.'; +import type { Importer } from './index.js'; const ignoreImports: Importer = function (): null { return null; diff --git a/packages/react-docgen/src/importer/index.ts b/packages/react-docgen/src/importer/index.ts index 07185e6d11b..4d57a815d64 100644 --- a/packages/react-docgen/src/importer/index.ts +++ b/packages/react-docgen/src/importer/index.ts @@ -4,9 +4,10 @@ import type { ExportNamedDeclaration, ImportDeclaration, } from '@babel/types'; -import type FileState from '../FileState'; -import ignoreImports from './ignoreImports'; -import fsImporter, { makeFsImporter } from './fsImporter'; +import type FileState from '../FileState.js'; +import ignoreImports from './ignoreImports.js'; +import fsImporter from './fsImporter.js'; +import makeFsImporter from './makeFsImporter.js'; export type ImportPath = NodePath< ExportAllDeclaration | ExportNamedDeclaration | ImportDeclaration diff --git a/packages/react-docgen/src/importer/makeFsImporter.ts b/packages/react-docgen/src/importer/makeFsImporter.ts new file mode 100644 index 00000000000..6861afffed6 --- /dev/null +++ b/packages/react-docgen/src/importer/makeFsImporter.ts @@ -0,0 +1,263 @@ +import { shallowIgnoreVisitors } from '../utils/traverse.js'; +import resolve from 'resolve'; +import { dirname, extname } from 'path'; +import fs from 'fs'; +import type { NodePath } from '@babel/traverse'; +import { visitors } from '@babel/traverse'; +import type { ExportSpecifier, Identifier, ObjectProperty } from '@babel/types'; +import type { Importer, ImportPath } from './index.js'; +import type FileState from '../FileState.js'; +import { resolveObjectPatternPropertyToValue } from '../utils/index.js'; + +const RESOLVE_EXTENSIONS = [ + '.js', + '.jsx', + '.cjs', + '.mjs', + '.ts', + '.tsx', + '.mts', + '.cts', +]; + +function defaultLookupModule(filename: string, basedir: string): string { + try { + return resolve.sync(filename, { + basedir, + extensions: RESOLVE_EXTENSIONS, + }); + } catch (error) { + const ext = extname(filename); + let newFilename: string; + + // if we try to import a JavaScript file it might be that we are actually pointing to + // a TypeScript file. This can happen in ES modules as TypeScript requires to import other + // TypeScript files with JavaScript extensions + // https://www.typescriptlang.org/docs/handbook/esm-node.html#type-in-packagejson-and-new-extensions + switch (ext) { + case '.js': + case '.mjs': + case '.cjs': + newFilename = `${filename.slice(0, -2)}ts`; + break; + + case '.jsx': + newFilename = `${filename.slice(0, -3)}tsx`; + break; + default: + throw error; + } + + return resolve.sync(newFilename, { + basedir, + extensions: RESOLVE_EXTENSIONS, + }); + } +} + +interface TraverseState { + readonly name: string; + readonly file: FileState; + readonly seen: Set; + resultPath?: NodePath | null; +} + +// Factory for the resolveImports importer +export default function makeFsImporter( + lookupModule: ( + filename: string, + basedir: string, + ) => string = defaultLookupModule, + cache: Map = new Map(), +): Importer { + function resolveImportedValue( + path: ImportPath, + name: string, + file: FileState, + seen: Set = new Set(), + ): NodePath | null { + // Bail if no filename was provided for the current source file. + // Also never traverse into react itself. + const source = path.node.source?.value; + const { filename } = file.opts; + + if (!source || !filename || source === 'react') { + return null; + } + + // Resolve the imported module using the Node resolver + const basedir = dirname(filename); + let resolvedSource: string | undefined; + + try { + resolvedSource = lookupModule(source, basedir); + } catch (error) { + const { code } = error as NodeJS.ErrnoException; + + if (code === 'MODULE_NOT_FOUND' || code === 'INVALID_PACKAGE_MAIN') { + return null; + } + + throw error; + } + + // Prevent recursive imports + if (seen.has(resolvedSource)) { + return null; + } + + seen.add(resolvedSource); + + let nextFile = cache.get(resolvedSource); + + if (!nextFile) { + // Read and parse the code + const src = fs.readFileSync(resolvedSource, 'utf8'); + + nextFile = file.parse(src, resolvedSource); + + cache.set(resolvedSource, nextFile); + } + + return findExportedValue(nextFile, name, seen); + } + + const explodedVisitors = visitors.explode({ + ...shallowIgnoreVisitors, + ExportNamedDeclaration: { + enter: function (path, state) { + const { file, name, seen } = state; + const declaration = path.get('declaration'); + + // export const/var ... + if (declaration.hasNode() && declaration.isVariableDeclaration()) { + for (const declPath of declaration.get('declarations')) { + const id = declPath.get('id'); + const init = declPath.get('init'); + + if (id.isIdentifier() && id.node.name === name && init.hasNode()) { + // export const/var a = + + state.resultPath = init; + + break; + } else if (id.isObjectPattern()) { + // export const/var { a } = + + state.resultPath = id.get('properties').find(prop => { + if (prop.isObjectProperty()) { + const value = prop.get('value'); + + return value.isIdentifier() && value.node.name === name; + } + // We don't handle RestElement here yet as complicated + + return false; + }); + + if (state.resultPath) { + state.resultPath = resolveObjectPatternPropertyToValue( + state.resultPath as NodePath, + ); + + break; + } + } + // ArrayPattern not handled yet + } + } else if ( + declaration.hasNode() && + declaration.has('id') && + (declaration.get('id') as NodePath).isIdentifier() && + (declaration.get('id') as NodePath).node.name === name + ) { + // export function/class/type/interface/enum ... + + state.resultPath = declaration; + } else if (path.has('specifiers')) { + // export { ... } or export x from ... or export * as x from ... + + for (const specifierPath of path.get('specifiers')) { + if (specifierPath.isExportNamespaceSpecifier()) { + continue; + } + const exported = specifierPath.get('exported'); + + if (exported.isIdentifier() && exported.node.name === name) { + // export ... from '' + if (path.has('source')) { + const local = specifierPath.isExportSpecifier() + ? specifierPath.node.local.name + : 'default'; + + state.resultPath = resolveImportedValue( + path, + local, + file, + seen, + ); + if (state.resultPath) { + break; + } + } else { + state.resultPath = ( + specifierPath as NodePath + ).get('local'); + + break; + } + } + } + } + + state.resultPath ? path.stop() : path.skip(); + }, + }, + ExportDefaultDeclaration: { + enter: function (path, state) { + const { name } = state; + + if (name === 'default') { + state.resultPath = path.get('declaration'); + + return path.stop(); + } + + path.skip(); + }, + }, + ExportAllDeclaration: { + enter: function (path, state) { + const { name, file, seen } = state; + const resolvedPath = resolveImportedValue(path, name, file, seen); + + if (resolvedPath) { + state.resultPath = resolvedPath; + + return path.stop(); + } + + path.skip(); + }, + }, + }); + + // Traverses the program looking for an export that matches the requested name + function findExportedValue( + file: FileState, + name: string, + seen: Set, + ): NodePath | null { + const state: TraverseState = { + file, + name, + seen, + }; + + file.traverse(explodedVisitors, state); + + return state.resultPath || null; + } + + return resolveImportedValue; +} diff --git a/packages/react-docgen/src/main.ts b/packages/react-docgen/src/main.ts index efc4813792b..6bf00e6fb94 100644 --- a/packages/react-docgen/src/main.ts +++ b/packages/react-docgen/src/main.ts @@ -1,15 +1,15 @@ -import * as allHandlers from './handlers'; -import parse from './parse'; -import * as allResolvers from './resolver'; -import * as allImporters from './importer'; -import * as utils from './utils'; -import type { DocumentationObject as Documentation } from './Documentation'; -import type { Resolver } from './resolver'; -import type { Importer } from './importer'; -import type { Handler } from './handlers'; -import type FileState from './FileState'; -import type { Config } from './config'; -import { createConfig, defaultHandlers } from './config'; +import * as allHandlers from './handlers/index.js'; +import parse from './parse.js'; +import * as allResolvers from './resolver/index.js'; +import * as allImporters from './importer/index.js'; +import * as utils from './utils/index.js'; +import type { DocumentationObject as Documentation } from './Documentation.js'; +import type { Resolver } from './resolver/index.js'; +import type { Importer } from './importer/index.js'; +import type { Handler } from './handlers/index.js'; +import type FileState from './FileState.js'; +import type { Config } from './config.js'; +import { createConfig, defaultHandlers } from './config.js'; declare module '@babel/traverse' { export interface HubInterface { diff --git a/packages/react-docgen/src/parse.ts b/packages/react-docgen/src/parse.ts index 80d07cdbac9..53f55d81958 100644 --- a/packages/react-docgen/src/parse.ts +++ b/packages/react-docgen/src/parse.ts @@ -1,12 +1,12 @@ -import Documentation from './Documentation'; -import type { DocumentationObject } from './Documentation'; -import postProcessDocumentation from './utils/postProcessDocumentation'; -import babelParse from './babelParser'; +import Documentation from './Documentation.js'; +import type { DocumentationObject } from './Documentation.js'; +import postProcessDocumentation from './utils/postProcessDocumentation.js'; +import babelParse from './babelParser.js'; import type { NodePath } from '@babel/traverse'; -import type { Handler } from './handlers'; -import type { ComponentNode } from './resolver'; -import FileState from './FileState'; -import type { InternalConfig } from './config'; +import type { Handler } from './handlers/index.js'; +import type { ComponentNode } from './resolver/index.js'; +import FileState from './FileState.js'; +import type { InternalConfig } from './config.js'; const ERROR_MISSING_DEFINITION = 'No suitable component definition found.'; diff --git a/packages/react-docgen/src/resolver/__tests__/__snapshots__/findAllExportedComponentDefinitions-test.ts.snap b/packages/react-docgen/src/resolver/__tests__/__snapshots__/findAllExportedComponentDefinitions-test.ts.snap index 0d1243b265a..bfa93165b42 100644 --- a/packages/react-docgen/src/resolver/__tests__/__snapshots__/findAllExportedComponentDefinitions-test.ts.snap +++ b/packages/react-docgen/src/resolver/__tests__/__snapshots__/findAllExportedComponentDefinitions-test.ts.snap @@ -1,8 +1,8 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`findAllExportedComponentDefinitions CommonJS module exports React.createClass does not process X.createClass of other modules 1`] = `[]`; +exports[`findAllExportedComponentDefinitions > CommonJS module exports > React.createClass > does not process X.createClass of other modules 1`] = `[]`; -exports[`findAllExportedComponentDefinitions CommonJS module exports React.createClass finds React.createClass 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > React.createClass > finds React.createClass 1`] = ` [ Node { "properties": [], @@ -11,7 +11,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports React.creat ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports React.createClass finds React.createClass, independent of the var name 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > React.createClass > finds React.createClass, independent of the var name 1`] = ` [ Node { "properties": [], @@ -20,7 +20,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports React.creat ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports React.createClass resolves an imported variable to React.createClass 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > React.createClass > resolves an imported variable to React.createClass 1`] = ` [ Node { "properties": [], @@ -29,7 +29,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports React.creat ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports class definitions finds class declarations 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > class definitions > finds class declarations 1`] = ` [ Node { "body": Node { @@ -57,7 +57,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports class defin ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports class definitions finds class definition, independent of the var name 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > class definitions > finds class definition, independent of the var name 1`] = ` [ Node { "body": Node { @@ -85,7 +85,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports class defin ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports class definitions finds class expression 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > class definitions > finds class expression 1`] = ` [ Node { "body": Node { @@ -110,7 +110,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports class defin ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports class definitions resolves an imported variable to class declaration 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > class definitions > resolves an imported variable to class declaration 1`] = ` [ Node { "body": Node { @@ -138,7 +138,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports class defin ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports class definitions resolves an imported variable to class expression 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > class definitions > resolves an imported variable to class expression 1`] = ` [ Node { "body": Node { @@ -163,7 +163,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports class defin ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports forwardRef components finds forwardRef components 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > forwardRef components > finds forwardRef components 1`] = ` [ Node { "arguments": [ @@ -271,7 +271,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports forwardRef ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports forwardRef components finds none inline forwardRef components 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > forwardRef components > finds none inline forwardRef components 1`] = ` [ Node { "arguments": [ @@ -297,7 +297,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports forwardRef ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports forwardRef components resolves an imported forwardRef component 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > forwardRef components > resolves an imported forwardRef component 1`] = ` [ Node { "arguments": [ @@ -405,7 +405,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports forwardRef ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; React.createClass finds assignments to exports 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > React.createClass > finds assignments to exports 1`] = ` [ Node { "properties": [], @@ -414,7 +414,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; React.createClass finds exported components only once 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > React.createClass > finds exported components only once 1`] = ` [ Node { "properties": [], @@ -423,7 +423,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; React.createClass finds multiple exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > React.createClass > finds multiple exported components 1`] = ` [ Node { "properties": [], @@ -436,7 +436,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; React.createClass finds multiple exported components with hocs 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > React.createClass > finds multiple exported components with hocs 1`] = ` [ Node { "properties": [], @@ -449,7 +449,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; React.createClass finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > React.createClass > finds only exported components 1`] = ` [ Node { "properties": [], @@ -458,7 +458,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; React.createClass finds only exported components on export 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > React.createClass > finds only exported components on export 1`] = ` [ Node { "properties": [], @@ -467,7 +467,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; React.createClass supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > React.createClass > supports imported components 1`] = ` [ Node { "properties": [], @@ -476,7 +476,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; class definition finds assignments to exports 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > class definition > finds assignments to exports 1`] = ` [ Node { "body": Node { @@ -504,7 +504,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; class definition finds exported components only once 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > class definition > finds exported components only once 1`] = ` [ Node { "body": Node { @@ -532,7 +532,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; class definition finds multiple exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > class definition > finds multiple exported components 1`] = ` [ Node { "body": Node { @@ -583,7 +583,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; class definition finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > class definition > finds only exported components 1`] = ` [ Node { "body": Node { @@ -611,7 +611,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; class definition finds only exported components on export 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > class definition > finds only exported components on export 1`] = ` [ Node { "body": Node { @@ -639,7 +639,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports module.exports = ; / exports.foo = ; class definition supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > module.exports = ; / exports.foo = ; > class definition > supports imported components 1`] = ` [ Node { "body": Node { @@ -667,9 +667,9 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports module.expo ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports stateless components does not process X.createElement of other modules 1`] = `[]`; +exports[`findAllExportedComponentDefinitions > CommonJS module exports > stateless components > does not process X.createElement of other modules 1`] = `[]`; -exports[`findAllExportedComponentDefinitions CommonJS module exports stateless components finds stateless component with JSX 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > stateless components > finds stateless component with JSX 1`] = ` [ Node { "async": false, @@ -695,7 +695,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports stateless c ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports stateless components finds stateless components with React.createElement, independent of the var name 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > stateless components > finds stateless components with React.createElement, independent of the var name 1`] = ` [ Node { "async": false, @@ -736,7 +736,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports stateless c ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports stateless components resolves an imported stateless component with JSX 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > stateless components > resolves an imported stateless component with JSX 1`] = ` [ Node { "async": false, @@ -762,7 +762,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports stateless c ] `; -exports[`findAllExportedComponentDefinitions CommonJS module exports stateless components resolves an imported stateless component with React.createElement 1`] = ` +exports[`findAllExportedComponentDefinitions > CommonJS module exports > stateless components > resolves an imported stateless component with React.createElement 1`] = ` [ Node { "async": false, @@ -803,7 +803,7 @@ exports[`findAllExportedComponentDefinitions CommonJS module exports stateless c ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export ; class definition finds multiple components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export ; > class definition > finds multiple components 1`] = ` [ Node { "body": Node { @@ -854,7 +854,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export ; ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export ; class definition finds named exports 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export ; > class definition > finds named exports 1`] = ` [ Node { "body": Node { @@ -882,7 +882,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export ; ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export ; class definition finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export ; > class definition > finds only exported components 1`] = ` [ Node { "body": Node { @@ -910,7 +910,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export ; ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export ; function declaration finds multiple components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export ; > function declaration > finds multiple components 1`] = ` [ Node { "async": false, @@ -981,7 +981,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export ; ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export ; function declaration finds named exports 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export ; > function declaration > finds named exports 1`] = ` [ Node { "async": false, @@ -1019,7 +1019,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export ; ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export ; function declaration finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export ; > function declaration > finds only exported components 1`] = ` [ Node { "async": false, @@ -1057,7 +1057,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export ; ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; React.createClass finds exported components only once 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > React.createClass > finds exported components only once 1`] = ` [ Node { "properties": [], @@ -1066,7 +1066,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; React.createClass finds exported specifiers 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > React.createClass > finds exported specifiers 1`] = ` [ Node { "properties": [], @@ -1075,7 +1075,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; React.createClass finds exported specifiers 2 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > React.createClass > finds exported specifiers 2 1`] = ` [ Node { "properties": [], @@ -1084,7 +1084,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; React.createClass finds exported specifiers 3 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > React.createClass > finds exported specifiers 3 1`] = ` [ Node { "properties": [], @@ -1093,7 +1093,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; React.createClass finds multiple components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > React.createClass > finds multiple components 1`] = ` [ Node { "properties": [], @@ -1106,7 +1106,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; React.createClass finds multiple components with hocs 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > React.createClass > finds multiple components with hocs 1`] = ` [ Node { "properties": [], @@ -1119,7 +1119,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; React.createClass finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > React.createClass > finds only exported components 1`] = ` [ Node { "properties": [], @@ -1128,7 +1128,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; React.createClass supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > React.createClass > supports imported components 1`] = ` [ Node { "properties": [], @@ -1137,7 +1137,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; class definition finds exported components only once 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > class definition > finds exported components only once 1`] = ` [ Node { "body": Node { @@ -1162,7 +1162,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; class definition finds exported specifiers 1 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > class definition > finds exported specifiers 1 1`] = ` [ Node { "body": Node { @@ -1187,7 +1187,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; class definition finds exported specifiers 2 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > class definition > finds exported specifiers 2 1`] = ` [ Node { "body": Node { @@ -1212,7 +1212,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; class definition finds exported specifiers 3 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > class definition > finds exported specifiers 3 1`] = ` [ Node { "body": Node { @@ -1237,7 +1237,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; class definition finds multiple components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > class definition > finds multiple components 1`] = ` [ Node { "body": Node { @@ -1282,7 +1282,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; class definition finds multiple components with hocs 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > class definition > finds multiple components with hocs 1`] = ` [ Node { "body": Node { @@ -1333,7 +1333,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; class definition finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > class definition > finds only exported components 1`] = ` [ Node { "body": Node { @@ -1358,7 +1358,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; class definition supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > class definition > supports imported components 1`] = ` [ Node { "body": Node { @@ -1386,7 +1386,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; forwardRef components finds forwardRef components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > forwardRef components > finds forwardRef components 1`] = ` [ Node { "arguments": [ @@ -1494,7 +1494,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; forwardRef components supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > forwardRef components > supports imported components 1`] = ` [ Node { "arguments": [ @@ -1602,7 +1602,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; stateless components finds exported components only once 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > stateless components > finds exported components only once 1`] = ` [ Node { "async": false, @@ -1628,7 +1628,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; stateless components finds exported specifiers 1 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > stateless components > finds exported specifiers 1 1`] = ` [ Node { "async": false, @@ -1666,7 +1666,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; stateless components finds exported specifiers 2 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > stateless components > finds exported specifiers 2 1`] = ` [ Node { "async": false, @@ -1692,7 +1692,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; stateless components finds exported specifiers 3 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > stateless components > finds exported specifiers 3 1`] = ` [ Node { "async": false, @@ -1727,7 +1727,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; stateless components finds multiple components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > stateless components > finds multiple components 1`] = ` [ Node { "async": false, @@ -1786,7 +1786,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; stateless components finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > stateless components > finds only exported components 1`] = ` [ Node { "async": false, @@ -1812,7 +1812,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export {}; stateless components supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export {}; > stateless components > supports imported components 1`] = ` [ Node { "async": false, @@ -1874,7 +1874,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export { ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; React.createClass finds default export 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > React.createClass > finds default export 1`] = ` [ Node { "properties": [], @@ -1883,7 +1883,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; React.createClass finds multiple exported components with export var 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > React.createClass > finds multiple exported components with export var 1`] = ` [ Node { "properties": [], @@ -1896,7 +1896,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; React.createClass finds multiple exported components with named export 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > React.createClass > finds multiple exported components with named export 1`] = ` [ Node { "properties": [], @@ -1909,7 +1909,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; React.createClass finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > React.createClass > finds only exported components 1`] = ` [ Node { "properties": [], @@ -1918,7 +1918,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; React.createClass finds reassigned default export 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > React.createClass > finds reassigned default export 1`] = ` [ Node { "properties": [], @@ -1927,7 +1927,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; React.createClass supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > React.createClass > supports imported components 1`] = ` [ Node { "properties": [], @@ -1936,7 +1936,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; class definition finds default export 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > class definition > finds default export 1`] = ` [ Node { "body": Node { @@ -1964,7 +1964,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; class definition finds default export inline 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > class definition > finds default export inline 1`] = ` [ Node { "body": Node { @@ -1992,7 +1992,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; class definition finds multiple exported components with export var 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > class definition > finds multiple exported components with export var 1`] = ` [ Node { "body": Node { @@ -2040,7 +2040,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; class definition finds multiple exported components with named export 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > class definition > finds multiple exported components with named export 1`] = ` [ Node { "body": Node { @@ -2088,7 +2088,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; class definition finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > class definition > finds only exported components 1`] = ` [ Node { "body": Node { @@ -2116,7 +2116,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; class definition supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > class definition > supports imported components 1`] = ` [ Node { "body": Node { @@ -2144,7 +2144,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; forwardRef components finds forwardRef components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > forwardRef components > finds forwardRef components 1`] = ` [ Node { "arguments": [ @@ -2252,7 +2252,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; forwardRef components finds none inline forwardRef components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > forwardRef components > finds none inline forwardRef components 1`] = ` [ Node { "arguments": [ @@ -2278,7 +2278,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export default ; forwardRef components supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export default ; > forwardRef components > supports imported components 1`] = ` [ Node { "arguments": [ @@ -2386,7 +2386,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export defa ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; React.createClass finds multiple components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > React.createClass > finds multiple components 1`] = ` [ Node { "properties": [], @@ -2399,7 +2399,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; React.createClass finds multiple components with separate export statements 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > React.createClass > finds multiple components with separate export statements 1`] = ` [ Node { "properties": [], @@ -2412,7 +2412,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; React.createClass finds named exports 1 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > React.createClass > finds named exports 1 1`] = ` [ Node { "properties": [], @@ -2421,7 +2421,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; React.createClass finds named exports 2 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > React.createClass > finds named exports 2 1`] = ` [ Node { "properties": [], @@ -2430,7 +2430,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; React.createClass finds named exports 3 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > React.createClass > finds named exports 3 1`] = ` [ Node { "properties": [], @@ -2439,7 +2439,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; React.createClass finds named exports 4 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > React.createClass > finds named exports 4 1`] = ` [ Node { "properties": [], @@ -2448,7 +2448,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; React.createClass finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > React.createClass > finds only exported components 1`] = ` [ Node { "properties": [], @@ -2457,7 +2457,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; React.createClass supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > React.createClass > supports imported components 1`] = ` [ Node { "properties": [], @@ -2466,7 +2466,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; class definition finds multiple components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > class definition > finds multiple components 1`] = ` [ Node { "body": Node { @@ -2511,7 +2511,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; class definition finds multiple components with assigned component 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > class definition > finds multiple components with assigned component 1`] = ` [ Node { "body": Node { @@ -2556,7 +2556,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; class definition finds named exports 1 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > class definition > finds named exports 1 1`] = ` [ Node { "body": Node { @@ -2581,7 +2581,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; class definition finds named exports 2 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > class definition > finds named exports 2 1`] = ` [ Node { "body": Node { @@ -2606,7 +2606,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; class definition finds named exports 3 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > class definition > finds named exports 3 1`] = ` [ Node { "body": Node { @@ -2631,7 +2631,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; class definition finds named exports 4 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > class definition > finds named exports 4 1`] = ` [ Node { "body": Node { @@ -2656,7 +2656,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; class definition finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > class definition > finds only exported components 1`] = ` [ Node { "body": Node { @@ -2681,7 +2681,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; class definition supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > class definition > supports imported components 1`] = ` [ Node { "body": Node { @@ -2709,7 +2709,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; forwardRef components finds forwardRef components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > forwardRef components > finds forwardRef components 1`] = ` [ Node { "arguments": [ @@ -2817,7 +2817,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; forwardRef components supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > forwardRef components > supports imported components 1`] = ` [ Node { "arguments": [ @@ -2925,7 +2925,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; stateless components finds multiple components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > stateless components > finds multiple components 1`] = ` [ Node { "async": false, @@ -2972,7 +2972,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; stateless components finds multiple components with named export 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > stateless components > finds multiple components with named export 1`] = ` [ Node { "async": false, @@ -3019,7 +3019,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; stateless components finds named exports 1 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > stateless components > finds named exports 1 1`] = ` [ Node { "async": false, @@ -3045,7 +3045,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; stateless components finds only exported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > stateless components > finds only exported components 1`] = ` [ Node { "async": false, @@ -3080,7 +3080,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; stateless components supports imported components 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > stateless components > supports imported components 1`] = ` [ Node { "async": false, @@ -3142,7 +3142,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; stateless components supports imported components 2 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > stateless components > supports imported components 2 1`] = ` [ Node { "async": false, @@ -3168,7 +3168,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; stateless components supports imported components 3 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > stateless components > supports imported components 3 1`] = ` [ Node { "async": false, @@ -3194,7 +3194,7 @@ exports[`findAllExportedComponentDefinitions ES6 export declarations export var ] `; -exports[`findAllExportedComponentDefinitions ES6 export declarations export var foo = , ...; stateless components supports imported components 4 1`] = ` +exports[`findAllExportedComponentDefinitions > ES6 export declarations > export var foo = , ...; > stateless components > supports imported components 4 1`] = ` [ Node { "async": false, diff --git a/packages/react-docgen/src/resolver/__tests__/findAllComponentDefinitions-test.ts b/packages/react-docgen/src/resolver/__tests__/findAllComponentDefinitions-test.ts index 0f966c9a727..dd043ff6990 100644 --- a/packages/react-docgen/src/resolver/__tests__/findAllComponentDefinitions-test.ts +++ b/packages/react-docgen/src/resolver/__tests__/findAllComponentDefinitions-test.ts @@ -1,6 +1,7 @@ import { NodePath } from '@babel/traverse'; import { parse, makeMockImporter, noopImporter } from '../../../tests/utils'; -import findAllComponentDefinitions from '../findAllComponentDefinitions'; +import findAllComponentDefinitions from '../findAllComponentDefinitions.js'; +import { describe, expect, test } from 'vitest'; describe('findAllComponentDefinitions', () => { function findComponentsInSource( @@ -45,7 +46,7 @@ describe('findAllComponentDefinitions', () => { }); describe('React.createClass', () => { - it('finds React.createClass', () => { + test('finds React.createClass', () => { const source = ` var React = require("React"); var Component = React.createClass({}); @@ -60,7 +61,7 @@ describe('findAllComponentDefinitions', () => { expect(result[0].node.type).toBe('ObjectExpression'); }); - it('resolves imported values inside React.createClass', () => { + test('resolves imported values inside React.createClass', () => { const source = ` import obj from 'obj'; var React = require("React"); @@ -76,7 +77,7 @@ describe('findAllComponentDefinitions', () => { expect(result[0].node.type).toBe('ObjectExpression'); }); - it('finds React.createClass, independent of the var name', () => { + test('finds React.createClass, independent of the var name', () => { const source = ` var R = require("React"); var Component = R.createClass({}); @@ -89,7 +90,7 @@ describe('findAllComponentDefinitions', () => { expect(result.length).toBe(1); }); - it('does not process X.createClass of other modules', () => { + test('does not process X.createClass of other modules', () => { const source = ` var R = require("NoReact"); var Component = R.createClass({}); @@ -102,7 +103,7 @@ describe('findAllComponentDefinitions', () => { expect(result.length).toBe(0); }); - it('finds assignments to exports', () => { + test('finds assignments to exports', () => { const source = ` var R = require("React"); var Component = R.createClass({}); @@ -116,7 +117,7 @@ describe('findAllComponentDefinitions', () => { expect(result.length).toBe(1); }); - it('accepts multiple definitions', () => { + test('accepts multiple definitions', () => { let source = ` var R = require("React"); var ComponentA = R.createClass({}); @@ -143,7 +144,7 @@ describe('findAllComponentDefinitions', () => { }); describe('class definitions', () => { - it('finds component classes', () => { + test('finds component classes', () => { const source = ` import React from 'React'; class ComponentA extends React.Component {} @@ -159,7 +160,7 @@ describe('findAllComponentDefinitions', () => { expect(result.length).toBe(4); }); - it('resolves extends React.Component/React.PureComponent from import', () => { + test('resolves extends React.Component/React.PureComponent from import', () => { const source = ` import Component from 'reactComponent'; import PureComponent from 'reactPureComponent'; @@ -173,7 +174,7 @@ describe('findAllComponentDefinitions', () => { expect(result.length).toBe(2); }); - it('finds React.Component, independent of the var name', () => { + test('finds React.Component, independent of the var name', () => { const source = ` import R from 'React'; class Component extends R.Component {}; @@ -185,7 +186,7 @@ describe('findAllComponentDefinitions', () => { expect(result.length).toBe(1); }); - it('does not process X.Component of other modules', () => { + test('does not process X.Component of other modules', () => { const source = ` import R from 'FakeReact'; class Component extends R.Component {}; @@ -199,7 +200,7 @@ describe('findAllComponentDefinitions', () => { }); describe('stateless components', () => { - it('finds stateless components', () => { + test('finds stateless components', () => { const source = ` import React from 'React'; let ComponentA = () =>
; @@ -230,7 +231,7 @@ describe('findAllComponentDefinitions', () => { expect(result.length).toBe(7); }); - it('resolve renders from imports', () => { + test('resolve renders from imports', () => { const source = ` import jsxDiv from 'jsxDiv'; import createElement from 'createElement'; @@ -246,7 +247,7 @@ describe('findAllComponentDefinitions', () => { expect(result.length).toBe(3); }); - it('finds React.createElement, independent of the var name', () => { + test('finds React.createElement, independent of the var name', () => { const source = ` import AlphaBetters from 'react'; function ComponentA () { return AlphaBetters.createElement('div', null); } @@ -259,7 +260,7 @@ describe('findAllComponentDefinitions', () => { expect(result.length).toBe(1); }); - it('does not process X.createElement of other modules', () => { + test('does not process X.createElement of other modules', () => { const source = ` import R from 'FakeReact'; const ComponentA = () => R.createElement('div', null); @@ -273,7 +274,7 @@ describe('findAllComponentDefinitions', () => { }); describe('forwardRef components', () => { - it('finds forwardRef components', () => { + test('finds forwardRef components', () => { const source = ` import React from 'react'; import PropTypes from 'prop-types'; @@ -293,7 +294,7 @@ describe('findAllComponentDefinitions', () => { expect(result[0].node.type).toEqual('CallExpression'); }); - it('finds none inline forwardRef components', () => { + test('finds none inline forwardRef components', () => { const source = ` import React from 'react'; import PropTypes from 'prop-types'; @@ -313,7 +314,7 @@ describe('findAllComponentDefinitions', () => { expect(result[0].node.type).toEqual('CallExpression'); }); - it('resolves imported component wrapped with forwardRef', () => { + test('resolves imported component wrapped with forwardRef', () => { const source = ` import React from 'react'; import ColoredView from 'coloredView'; @@ -329,7 +330,7 @@ describe('findAllComponentDefinitions', () => { }); describe('regressions', () => { - it('finds component wrapped in HOC', () => { + test('finds component wrapped in HOC', () => { const source = ` /** * @flow diff --git a/packages/react-docgen/src/resolver/__tests__/findAllExportedComponentDefinitions-test.ts b/packages/react-docgen/src/resolver/__tests__/findAllExportedComponentDefinitions-test.ts index d0a2e9de83b..dbaab49b5c4 100644 --- a/packages/react-docgen/src/resolver/__tests__/findAllExportedComponentDefinitions-test.ts +++ b/packages/react-docgen/src/resolver/__tests__/findAllExportedComponentDefinitions-test.ts @@ -1,6 +1,7 @@ import type { NodePath } from '@babel/traverse'; import { parse, noopImporter, makeMockImporter } from '../../../tests/utils'; -import findAllExportedComponentDefinitions from '../findAllExportedComponentDefinitions'; +import findAllExportedComponentDefinitions from '../findAllExportedComponentDefinitions.js'; +import { describe, expect, test } from 'vitest'; describe('findAllExportedComponentDefinitions', () => { function findComponentsInSource( @@ -54,7 +55,7 @@ describe('findAllExportedComponentDefinitions', () => { describe('CommonJS module exports', () => { describe('React.createClass', () => { - it('finds React.createClass', () => { + test('finds React.createClass', () => { const result = findComponentsInSource(` var React = require("React"); var Component = React.createClass({}); @@ -64,7 +65,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds React.createClass, independent of the var name', () => { + test('finds React.createClass, independent of the var name', () => { const result = findComponentsInSource(` var R = require("React"); var Component = R.createClass({}); @@ -74,7 +75,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('does not process X.createClass of other modules', () => { + test('does not process X.createClass of other modules', () => { const result = findComponentsInSource(` var R = require("NoReact"); var Component = R.createClass({}); @@ -84,7 +85,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('resolves an imported variable to React.createClass', () => { + test('resolves an imported variable to React.createClass', () => { const result = findComponentsInSource( ` import Component from 'createClass'; @@ -98,7 +99,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('class definitions', () => { - it('finds class declarations', () => { + test('finds class declarations', () => { const result = findComponentsInSource(` var React = require("React"); class Component extends React.Component {} @@ -108,7 +109,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds class expression', () => { + test('finds class expression', () => { const result = findComponentsInSource(` var React = require("React"); var Component = class extends React.Component {} @@ -118,7 +119,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds class definition, independent of the var name', () => { + test('finds class definition, independent of the var name', () => { const result = findComponentsInSource(` var R = require("React"); class Component extends R.Component {} @@ -128,7 +129,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('resolves an imported variable to class declaration', () => { + test('resolves an imported variable to class declaration', () => { const result = findComponentsInSource( ` import Component from 'classDec'; @@ -140,7 +141,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('resolves an imported variable to class expression', () => { + test('resolves an imported variable to class expression', () => { const result = findComponentsInSource( ` import Component from 'classExpr'; @@ -154,7 +155,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('stateless components', () => { - it('finds stateless component with JSX', () => { + test('finds stateless component with JSX', () => { const result = findComponentsInSource(` var React = require("React"); var Component = () =>
; @@ -164,7 +165,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds stateless components with React.createElement, independent of the var name', () => { + test('finds stateless components with React.createElement, independent of the var name', () => { const result = findComponentsInSource(` var R = require("React"); var Component = () => R.createElement('div', {}); @@ -174,7 +175,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('does not process X.createElement of other modules', () => { + test('does not process X.createElement of other modules', () => { const result = findComponentsInSource(` var R = require("NoReact"); var Component = () => R.createElement({}); @@ -184,7 +185,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('resolves an imported stateless component with JSX', () => { + test('resolves an imported stateless component with JSX', () => { const result = findComponentsInSource( ` import Component from 'statelessJsx'; @@ -196,7 +197,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('resolves an imported stateless component with React.createElement', () => { + test('resolves an imported stateless component with React.createElement', () => { const result = findComponentsInSource( ` import Component from 'statelessCreateElement'; @@ -210,7 +211,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('forwardRef components', () => { - it('finds forwardRef components', () => { + test('finds forwardRef components', () => { const result = findComponentsInSource(` import React from 'react'; import PropTypes from 'prop-types'; @@ -226,7 +227,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds none inline forwardRef components', () => { + test('finds none inline forwardRef components', () => { const result = findComponentsInSource(` import React from 'react'; import PropTypes from 'prop-types'; @@ -244,7 +245,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('resolves an imported forwardRef component', () => { + test('resolves an imported forwardRef component', () => { const result = findComponentsInSource( ` import Component from 'forwardRef'; @@ -259,7 +260,7 @@ describe('findAllExportedComponentDefinitions', () => { describe('module.exports = ; / exports.foo = ;', () => { describe('React.createClass', () => { - it('finds assignments to exports', () => { + test('finds assignments to exports', () => { const result = findComponentsInSource(` var R = require("React"); var Component = R.createClass({}); @@ -270,7 +271,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple exported components', () => { + test('finds multiple exported components', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = R.createClass({}); @@ -282,7 +283,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple exported components with hocs', () => { + test('finds multiple exported components with hocs', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = R.createClass({}); @@ -294,7 +295,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components on export', () => { + test('finds only exported components on export', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = R.createClass({}); @@ -305,7 +306,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = R.createClass({}); @@ -316,7 +317,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported components only once', () => { + test('finds exported components only once', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = R.createClass({}); @@ -327,7 +328,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( ` import Component from 'createClass'; @@ -342,7 +343,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('class definition', () => { - it('finds assignments to exports', () => { + test('finds assignments to exports', () => { const result = findComponentsInSource(` var R = require("React"); class Component extends R.Component {} @@ -353,7 +354,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple exported components', () => { + test('finds multiple exported components', () => { const result = findComponentsInSource(` var R = require("React"); class ComponentA extends R.Component {} @@ -365,7 +366,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components on export', () => { + test('finds only exported components on export', () => { const result = findComponentsInSource(` var R = require("React"); class ComponentA extends R.Component {} @@ -376,7 +377,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` var R = require("React"); class ComponentA extends R.Component {} @@ -387,7 +388,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported components only once', () => { + test('finds exported components only once', () => { const result = findComponentsInSource(` var R = require("React"); class ComponentA extends R.Component {} @@ -398,7 +399,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( ` import Component from 'classDec'; @@ -417,7 +418,7 @@ describe('findAllExportedComponentDefinitions', () => { describe('ES6 export declarations', () => { describe('export default ;', () => { describe('React.createClass', () => { - it('finds reassigned default export', () => { + test('finds reassigned default export', () => { const result = findComponentsInSource(` var React = require("React"); var Component = React.createClass({}); @@ -427,7 +428,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds default export', () => { + test('finds default export', () => { const result = findComponentsInSource(` var React = require("React"); export default React.createClass({}); @@ -436,7 +437,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple exported components with export var', () => { + test('finds multiple exported components with export var', () => { const result = findComponentsInSource(` import React, { createElement } from "React" export var Component = React.createClass({}); @@ -446,7 +447,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple exported components with named export', () => { + test('finds multiple exported components with named export', () => { const result = findComponentsInSource(` import React, { createElement } from "React" var Component = React.createClass({}) @@ -457,7 +458,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` import React, { createElement } from "React" var Component = React.createClass({}) @@ -467,7 +468,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( `import Component from 'createClass'; export default Component;`, @@ -479,7 +480,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('class definition', () => { - it('finds default export', () => { + test('finds default export', () => { const result = findComponentsInSource(` import React from 'React'; class Component extends React.Component {} @@ -489,7 +490,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds default export inline', () => { + test('finds default export inline', () => { const result = findComponentsInSource(` import React from 'React'; export default class Component extends React.Component {}; @@ -498,7 +499,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple exported components with export var', () => { + test('finds multiple exported components with export var', () => { const result = findComponentsInSource(` import React from 'React'; export var Component = class extends React.Component {}; @@ -508,7 +509,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple exported components with named export', () => { + test('finds multiple exported components with named export', () => { const result = findComponentsInSource(` import React from 'React'; var Component = class extends React.Component {}; @@ -519,7 +520,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` import React from 'React'; var Component = class extends React.Component {}; @@ -529,7 +530,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( `import Component from 'classDec'; export default Component;`, @@ -541,7 +542,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('forwardRef components', () => { - it('finds forwardRef components', () => { + test('finds forwardRef components', () => { const result = findComponentsInSource(` import React from 'react'; import PropTypes from 'prop-types'; @@ -557,7 +558,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds none inline forwardRef components', () => { + test('finds none inline forwardRef components', () => { const result = findComponentsInSource(` import React from 'react'; import PropTypes from 'prop-types'; @@ -575,7 +576,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( `import Component from 'forwardRef'; export default Component;`, @@ -589,7 +590,7 @@ describe('findAllExportedComponentDefinitions', () => { describe('export var foo = , ...;', () => { describe('React.createClass', () => { - it('finds named exports 1', () => { + test('finds named exports 1', () => { const result = findComponentsInSource(` var React = require("React"); export var somethingElse = 42, Component = React.createClass({}); @@ -598,7 +599,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds named exports 2', () => { + test('finds named exports 2', () => { const result = findComponentsInSource(` var React = require("React"); export let Component = React.createClass({}), somethingElse = 42; @@ -607,7 +608,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds named exports 3', () => { + test('finds named exports 3', () => { const result = findComponentsInSource(` var React = require("React"); export const something = 21, @@ -618,7 +619,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds named exports 4', () => { + test('finds named exports 4', () => { const result = findComponentsInSource(` var React = require("React"); export var somethingElse = function() {}; @@ -628,7 +629,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components', () => { + test('finds multiple components', () => { const result = findComponentsInSource(` var R = require("React"); export var ComponentA = R.createClass({}), @@ -638,7 +639,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components with separate export statements', () => { + test('finds multiple components with separate export statements', () => { const result = findComponentsInSource(` var R = require("React"); export var ComponentA = R.createClass({}); @@ -649,7 +650,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = R.createClass({}); @@ -659,7 +660,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( `import Component from 'createClass'; export let ComponentA = Component; @@ -672,7 +673,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('class definition', () => { - it('finds named exports 1', () => { + test('finds named exports 1', () => { const result = findComponentsInSource(` import React from 'React'; export var somethingElse = 42, @@ -682,7 +683,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds named exports 2', () => { + test('finds named exports 2', () => { const result = findComponentsInSource(` import React from 'React'; export let Component = class extends React.Component {}, @@ -692,7 +693,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds named exports 3', () => { + test('finds named exports 3', () => { const result = findComponentsInSource(` import React from 'React'; export const something = 21, @@ -703,7 +704,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds named exports 4', () => { + test('finds named exports 4', () => { const result = findComponentsInSource(` import React from 'React'; export var somethingElse = function() {}; @@ -713,7 +714,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components', () => { + test('finds multiple components', () => { const result = findComponentsInSource(` import React from 'React'; export var ComponentA = class extends React.Component {}; @@ -723,7 +724,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components with assigned component', () => { + test('finds multiple components with assigned component', () => { const result = findComponentsInSource(` import React from 'React'; export var ComponentA = class extends React.Component {}; @@ -734,7 +735,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` import React from 'React'; var ComponentA = class extends React.Component {} @@ -744,7 +745,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( ` import Component from 'classDec'; @@ -759,7 +760,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('stateless components', () => { - it('finds named exports 1', () => { + test('finds named exports 1', () => { const result = findComponentsInSource(` import React from 'React'; export var somethingElse = 42, @@ -769,7 +770,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components 2', () => { + test('supports imported components 2', () => { const result = findComponentsInSource(` import React from 'React'; export let Component = () =>
, @@ -779,7 +780,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components 3', () => { + test('supports imported components 3', () => { const result = findComponentsInSource(` import React from 'React'; export const something = 21, @@ -790,7 +791,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components 4', () => { + test('supports imported components 4', () => { const result = findComponentsInSource(` import React from 'React'; export var somethingElse = function() {}; @@ -800,7 +801,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components', () => { + test('finds multiple components', () => { const result = findComponentsInSource(` import React from 'React'; export var ComponentA = () =>
@@ -810,7 +811,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components with named export', () => { + test('finds multiple components with named export', () => { const result = findComponentsInSource(` import React from 'React'; export var ComponentA = () =>
@@ -821,7 +822,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` import React from 'React'; var ComponentA = class extends React.Component {} @@ -831,7 +832,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( `import Component1 from 'statelessJsx'; import Component2 from 'statelessCreateElement'; @@ -844,7 +845,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('forwardRef components', () => { - it('finds forwardRef components', () => { + test('finds forwardRef components', () => { const result = findComponentsInSource(` import React from 'react'; import PropTypes from 'prop-types'; @@ -858,7 +859,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( ` import Component from 'forwardRef'; @@ -875,7 +876,7 @@ describe('findAllExportedComponentDefinitions', () => { describe('export {};', () => { describe('React.createClass', () => { - it('finds exported specifiers', () => { + test('finds exported specifiers', () => { const result = findComponentsInSource(` var React = require("React"); var foo = 42; @@ -886,7 +887,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported specifiers 2', () => { + test('finds exported specifiers 2', () => { const result = findComponentsInSource(` import React from "React" var foo = 42; @@ -897,7 +898,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported specifiers 3', () => { + test('finds exported specifiers 3', () => { const result = findComponentsInSource(` import React, { createElement } from "React" var foo = 42; @@ -909,7 +910,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components', () => { + test('finds multiple components', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = R.createClass({}); @@ -920,7 +921,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components with hocs', () => { + test('finds multiple components with hocs', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = hoc(R.createClass({})); @@ -931,7 +932,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = R.createClass({}); @@ -942,7 +943,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported components only once', () => { + test('finds exported components only once', () => { const result = findComponentsInSource(` var R = require("React"); var ComponentA = R.createClass({}); @@ -952,7 +953,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( `import Component from 'createClass'; export { Component, Component as ComponentB };`, @@ -964,7 +965,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('class definition', () => { - it('finds exported specifiers 1', () => { + test('finds exported specifiers 1', () => { const result = findComponentsInSource(` import React from 'React'; var foo = 42; @@ -975,7 +976,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported specifiers 2', () => { + test('finds exported specifiers 2', () => { const result = findComponentsInSource(` import React from 'React'; var foo = 42; @@ -986,7 +987,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported specifiers 3', () => { + test('finds exported specifiers 3', () => { const result = findComponentsInSource(` import React from 'React'; var foo = 42; @@ -998,7 +999,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components', () => { + test('finds multiple components', () => { const result = findComponentsInSource(` import React from 'React'; var ComponentA = class extends React.Component {}; @@ -1009,7 +1010,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components with hocs', () => { + test('finds multiple components with hocs', () => { const result = findComponentsInSource(` import React from 'React'; class ComponentA extends React.Component {}; @@ -1022,7 +1023,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` import React from 'React'; var ComponentA = class extends React.Component {}; @@ -1033,7 +1034,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported components only once', () => { + test('finds exported components only once', () => { const result = findComponentsInSource(` import React from 'React'; var ComponentA = class extends React.Component {}; @@ -1044,7 +1045,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( ` import Component from 'classDec'; @@ -1058,7 +1059,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('stateless components', () => { - it('finds exported specifiers 1', () => { + test('finds exported specifiers 1', () => { const result = findComponentsInSource(` import React from 'React'; var foo = 42; @@ -1069,7 +1070,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported specifiers 2', () => { + test('finds exported specifiers 2', () => { const result = findComponentsInSource(` import React from 'React'; var foo = 42; @@ -1080,7 +1081,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported specifiers 3', () => { + test('finds exported specifiers 3', () => { const result = findComponentsInSource(` import React from 'React'; var foo = 42; @@ -1092,7 +1093,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components', () => { + test('finds multiple components', () => { const result = findComponentsInSource(` import React from 'React'; var ComponentA = () =>
; @@ -1103,7 +1104,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` import React from 'React'; var ComponentA = () =>
; @@ -1114,7 +1115,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds exported components only once', () => { + test('finds exported components only once', () => { const result = findComponentsInSource(` import React from 'React'; var ComponentA = () =>
; @@ -1125,7 +1126,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( ` import ComponentA from 'statelessJsx'; @@ -1140,7 +1141,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('forwardRef components', () => { - it('finds forwardRef components', () => { + test('finds forwardRef components', () => { const result = findComponentsInSource(` import React from 'react'; import PropTypes from 'prop-types'; @@ -1156,7 +1157,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('supports imported components', () => { + test('supports imported components', () => { const result = findComponentsInSource( ` import Component from 'forwardRef'; @@ -1172,7 +1173,7 @@ describe('findAllExportedComponentDefinitions', () => { describe('export ;', () => { describe('class definition', () => { - it('finds named exports', () => { + test('finds named exports', () => { const result = findComponentsInSource(` import React from 'React'; export var foo = 42; @@ -1182,7 +1183,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components', () => { + test('finds multiple components', () => { const result = findComponentsInSource(` import React from 'React'; export class ComponentA extends React.Component {}; @@ -1192,7 +1193,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` import React from 'React'; class ComponentA extends React.Component {}; @@ -1204,7 +1205,7 @@ describe('findAllExportedComponentDefinitions', () => { }); describe('function declaration', () => { - it('finds named exports', () => { + test('finds named exports', () => { const result = findComponentsInSource(` import React from 'React'; export var foo = 42; @@ -1214,7 +1215,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds multiple components', () => { + test('finds multiple components', () => { const result = findComponentsInSource(` import React from 'React'; export function ComponentA() { return
; }; @@ -1224,7 +1225,7 @@ describe('findAllExportedComponentDefinitions', () => { expect(result).toMatchSnapshot(); }); - it('finds only exported components', () => { + test('finds only exported components', () => { const result = findComponentsInSource(` import React from 'React'; function ComponentA() { return
; } diff --git a/packages/react-docgen/src/resolver/__tests__/findExportedComponentDefinition-test.ts b/packages/react-docgen/src/resolver/__tests__/findExportedComponentDefinition-test.ts index e9a3f865ce9..59b5514950f 100644 --- a/packages/react-docgen/src/resolver/__tests__/findExportedComponentDefinition-test.ts +++ b/packages/react-docgen/src/resolver/__tests__/findExportedComponentDefinition-test.ts @@ -1,6 +1,7 @@ import type { NodePath } from '@babel/traverse'; import { noopImporter, makeMockImporter, parse } from '../../../tests/utils'; -import findExportedComponentDefinition from '../findExportedComponentDefinition'; +import findExportedComponentDefinition from '../findExportedComponentDefinition.js'; +import { describe, expect, test } from 'vitest'; describe('findExportedComponentDefinition', () => { function findComponentsInSource( @@ -50,7 +51,7 @@ describe('findExportedComponentDefinition', () => { describe('CommonJS module exports', () => { describe('React.createClass', () => { - it('finds React.createClass', () => { + test('finds React.createClass', () => { const source = ` var React = require("React"); var Component = React.createClass({}); @@ -63,7 +64,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds React.createClass with hoc', () => { + test('finds React.createClass with hoc', () => { const source = ` var React = require("React"); var Component = React.createClass({}); @@ -76,7 +77,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds React.createClass with hoc and args', () => { + test('finds React.createClass with hoc and args', () => { const source = ` var React = require("React"); var Component = React.createClass({}); @@ -89,7 +90,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds React.createClass with two hocs', () => { + test('finds React.createClass with two hocs', () => { const source = ` var React = require("React"); var Component = React.createClass({}); @@ -104,7 +105,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds React.createClass with three hocs', () => { + test('finds React.createClass with three hocs', () => { const source = ` var React = require("React"); var Component = React.createClass({}); @@ -121,7 +122,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds React.createClass, independent of the var name', () => { + test('finds React.createClass, independent of the var name', () => { const source = ` var R = require("React"); var Component = R.createClass({}); @@ -134,7 +135,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('does not process X.createClass of other modules', () => { + test('does not process X.createClass of other modules', () => { const source = ` var R = require("NoReact"); var Component = R.createClass({}); @@ -147,7 +148,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(0); }); - it('resolves an imported variable to React.createClass', () => { + test('resolves an imported variable to React.createClass', () => { const source = ` import Component from 'createClass'; module.exports = Component; @@ -161,7 +162,7 @@ describe('findExportedComponentDefinition', () => { }); describe('class definitions', () => { - it('finds class declarations', () => { + test('finds class declarations', () => { const source = ` var React = require("React"); class Component extends React.Component {} @@ -175,7 +176,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('finds class expression', () => { + test('finds class expression', () => { const source = ` var React = require("React"); var Component = class extends React.Component {} @@ -189,7 +190,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassExpression'); }); - it('finds class definition, independent of the var name', () => { + test('finds class definition, independent of the var name', () => { const source = ` var R = require("React"); class Component extends R.Component {} @@ -203,7 +204,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('resolves an imported variable to class declaration', () => { + test('resolves an imported variable to class declaration', () => { const source = ` import Component from 'classDec'; module.exports = Component; @@ -216,7 +217,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('resolves an imported variable to class expression', () => { + test('resolves an imported variable to class expression', () => { const source = ` import Component from 'classExpr'; module.exports = Component; @@ -231,7 +232,7 @@ describe('findExportedComponentDefinition', () => { }); describe('stateless components', () => { - it('finds stateless component with JSX', () => { + test('finds stateless component with JSX', () => { const source = ` var React = require("React"); var Component = () =>
; @@ -244,7 +245,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds stateless components with React.createElement, independent of the var name', () => { + test('finds stateless components with React.createElement, independent of the var name', () => { const source = ` var R = require("React"); var Component = () => R.createElement('div', {}); @@ -257,7 +258,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('does not process X.createElement of other modules', () => { + test('does not process X.createElement of other modules', () => { const source = ` var R = require("NoReact"); var Component = () => R.createElement({}); @@ -270,7 +271,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(0); }); - it('resolves an imported stateless component with JSX', () => { + test('resolves an imported stateless component with JSX', () => { const source = ` import Component from 'statelessJsx'; module.exports = Component; @@ -282,7 +283,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('resolves an imported stateless component with React.createElement', () => { + test('resolves an imported stateless component with React.createElement', () => { const source = ` import Component from 'statelessCreateElement'; module.exports = Component; @@ -297,7 +298,7 @@ describe('findExportedComponentDefinition', () => { describe('module.exports = ; / exports.foo = ;', () => { describe('React.createClass', () => { - it('finds assignments to exports', () => { + test('finds assignments to exports', () => { const source = ` var R = require("React"); var Component = R.createClass({}); @@ -311,7 +312,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { const source = ` var R = require("React"); var ComponentA = R.createClass({}); @@ -323,7 +324,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported on exports', () => { + test('accepts multiple definitions if only one is exported on exports', () => { const source = ` var R = require("React"); var ComponentA = R.createClass({}); @@ -337,7 +338,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` var R = require("React"); var ComponentA = R.createClass({}); @@ -351,7 +352,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('supports imported components', () => { + test('supports imported components', () => { const source = ` import Component from 'createClass'; exports.ComponentB = Component; @@ -365,7 +366,7 @@ describe('findExportedComponentDefinition', () => { }); describe('class definition', () => { - it('finds assignments to exports', () => { + test('finds assignments to exports', () => { const source = ` var R = require("React"); class Component extends R.Component {} @@ -380,7 +381,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { const source = ` var R = require("React"); class ComponentA extends R.Component {} @@ -392,7 +393,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { let source = ` var R = require("React"); class ComponentA extends R.Component {} @@ -419,7 +420,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('supports imported components', () => { + test('supports imported components', () => { const source = ` import Component from 'classDec'; exports.ComponentB = Component; @@ -438,7 +439,7 @@ describe('findExportedComponentDefinition', () => { describe('ES6 export declarations', () => { describe('export default ;', () => { describe('React.createClass', () => { - it('finds default export', () => { + test('finds default export', () => { const source = ` var React = require("React"); var Component = React.createClass({}); @@ -451,7 +452,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds default export inline', () => { + test('finds default export inline', () => { const source = ` var React = require("React"); export default React.createClass({}); @@ -463,7 +464,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { const source = ` import React, { createElement } from "React" export var Component = React.createClass({}) @@ -473,7 +474,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('errors if multiple components are exported with named export', () => { + test('errors if multiple components are exported with named export', () => { const source = ` import React, { createElement } from "React" var Component = React.createClass({}) @@ -484,7 +485,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` import React, { createElement } from "React" var Component = React.createClass({}) @@ -497,7 +498,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('supports imported components', () => { + test('supports imported components', () => { const source = ` import Component from 'createClass'; export default Component; @@ -511,7 +512,7 @@ describe('findExportedComponentDefinition', () => { }); describe('class definition', () => { - it('finds default export', () => { + test('finds default export', () => { let source = ` import React from 'React'; class Component extends React.Component {} @@ -535,7 +536,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('finds default export with hoc', () => { + test('finds default export with hoc', () => { const source = ` import React from 'React'; class Component extends React.Component {} @@ -549,7 +550,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('finds default export with hoc and args', () => { + test('finds default export with hoc and args', () => { const source = ` import React from 'React'; class Component extends React.Component {} @@ -563,7 +564,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('finds default export with two hocs', () => { + test('finds default export with two hocs', () => { const source = ` import React from 'React'; class Component extends React.Component {} @@ -579,7 +580,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { let source = ` import React from 'React'; export var Component = class extends React.Component {}; @@ -597,7 +598,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` import React from 'React'; var Component = class extends React.Component {}; @@ -611,7 +612,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('supports imported components', () => { + test('supports imported components', () => { const source = ` import Component from 'classDec'; export default Component; @@ -628,7 +629,7 @@ describe('findExportedComponentDefinition', () => { describe('export var foo = , ...;', () => { describe('React.createClass', () => { - it('finds named exports with export var', () => { + test('finds named exports with export var', () => { const source = ` var React = require("React"); export var somethingElse = 42, Component = React.createClass({}); @@ -640,7 +641,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds named exports with export let', () => { + test('finds named exports with export let', () => { const source = ` var React = require("React"); export let Component = React.createClass({}), somethingElse = 42; @@ -652,7 +653,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds named exports with export const', () => { + test('finds named exports with export const', () => { const source = ` var React = require("React"); export const something = 21, @@ -666,7 +667,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds named exports with export let and additional export', () => { + test('finds named exports with export let and additional export', () => { const source = ` var React = require("React"); export var somethingElse = function() {}; @@ -679,7 +680,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { let source = ` var R = require("React"); export var ComponentA = R.createClass({}), @@ -698,7 +699,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` var R = require("React"); var ComponentA = R.createClass({}); @@ -711,7 +712,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('supports imported components', () => { + test('supports imported components', () => { const source = ` import Component from 'createClass'; export let ComponentB = Component; @@ -725,7 +726,7 @@ describe('findExportedComponentDefinition', () => { }); describe('class definition', () => { - it('finds named exports', () => { + test('finds named exports', () => { let source = ` import React from 'React'; export var somethingElse = 42, @@ -769,7 +770,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassExpression'); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { let source = ` import React from 'React'; export var ComponentA = class extends React.Component {}; @@ -787,7 +788,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` import React from 'React'; var ComponentA = class extends React.Component {} @@ -800,7 +801,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassExpression'); }); - it('supports imported components', () => { + test('supports imported components', () => { const source = ` import Component from 'classDec'; export let ComponentB = Component; @@ -815,7 +816,7 @@ describe('findExportedComponentDefinition', () => { }); describe('stateless components', () => { - it('finds named exports', () => { + test('finds named exports', () => { let source = ` import React from 'React'; export var somethingElse = 42, @@ -859,7 +860,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ArrowFunctionExpression'); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { let source = ` import React from 'React'; export var ComponentA = () =>
@@ -877,7 +878,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` import React from 'React'; var ComponentA = class extends React.Component {} @@ -890,7 +891,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('FunctionExpression'); }); - it('supports imported components', () => { + test('supports imported components', () => { let source = ` import Component from 'statelessJsx'; export var ComponentA = Component; @@ -917,7 +918,7 @@ describe('findExportedComponentDefinition', () => { describe('export {};', () => { describe('React.createClass', () => { - it('finds exported specifiers 1', () => { + test('finds exported specifiers 1', () => { const source = ` var React = require("React"); var foo = 42; @@ -930,7 +931,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds exported specifiers 2', () => { + test('finds exported specifiers 2', () => { const source = ` import React from "React" var foo = 42; @@ -944,7 +945,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('finds exported specifiers 3', () => { + test('finds exported specifiers 3', () => { const source = ` import React, { createElement } from "React" var foo = 42; @@ -959,7 +960,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { const source = ` var R = require("React"); var ComponentA = R.createClass({}); @@ -970,7 +971,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` var R = require("React"); var ComponentA = R.createClass({}); @@ -984,7 +985,7 @@ describe('findExportedComponentDefinition', () => { expect(result).toHaveLength(1); }); - it('supports imported components', () => { + test('supports imported components', () => { const source = ` import Component from 'createClass'; export { Component }; @@ -998,7 +999,7 @@ describe('findExportedComponentDefinition', () => { }); describe('class definition', () => { - it('finds exported specifiers', () => { + test('finds exported specifiers', () => { let source = ` import React from 'React'; var foo = 42; @@ -1035,7 +1036,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassExpression'); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { const source = ` import React from 'React'; var ComponentA = class extends React.Component {}; @@ -1046,7 +1047,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` import React from 'React'; var ComponentA = class extends React.Component {}; @@ -1060,7 +1061,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassExpression'); }); - it('supports imported components', () => { + test('supports imported components', () => { const source = ` import Component from 'classDec'; export { Component }; @@ -1075,7 +1076,7 @@ describe('findExportedComponentDefinition', () => { }); describe('stateless components', () => { - it('finds exported specifiers', () => { + test('finds exported specifiers', () => { let source = ` import React from 'React'; var foo = 42; @@ -1112,7 +1113,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('FunctionExpression'); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { const source = ` import React from 'React'; var ComponentA = () =>
; @@ -1123,7 +1124,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` import React from 'React'; var ComponentA = () =>
; @@ -1137,7 +1138,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ArrowFunctionExpression'); }); - it('supports imported components', () => { + test('supports imported components', () => { let source = ` import Component from 'statelessJsx'; export { Component as ComponentA }; @@ -1164,7 +1165,7 @@ describe('findExportedComponentDefinition', () => { // Only applies to classes describe('export ;', () => { - it('finds named exports', () => { + test('finds named exports', () => { const source = ` import React from 'React'; export var foo = 42; @@ -1177,7 +1178,7 @@ describe('findExportedComponentDefinition', () => { expect(result[0].node.type).toBe('ClassDeclaration'); }); - it('errors if multiple components are exported', () => { + test('errors if multiple components are exported', () => { const source = ` import React from 'React'; export class ComponentA extends React.Component {}; @@ -1187,7 +1188,7 @@ describe('findExportedComponentDefinition', () => { expect(() => findComponentsInSource(source)).toThrow(); }); - it('accepts multiple definitions if only one is exported', () => { + test('accepts multiple definitions if only one is exported', () => { const source = ` import React from 'React'; class ComponentA extends React.Component {}; diff --git a/packages/react-docgen/src/resolver/findAllComponentDefinitions.ts b/packages/react-docgen/src/resolver/findAllComponentDefinitions.ts index 47e1af82a30..7a83414f76e 100644 --- a/packages/react-docgen/src/resolver/findAllComponentDefinitions.ts +++ b/packages/react-docgen/src/resolver/findAllComponentDefinitions.ts @@ -1,13 +1,13 @@ -import isReactComponentClass from '../utils/isReactComponentClass'; -import isReactCreateClassCall from '../utils/isReactCreateClassCall'; -import isReactForwardRefCall from '../utils/isReactForwardRefCall'; -import isStatelessComponent from '../utils/isStatelessComponent'; -import normalizeClassDefinition from '../utils/normalizeClassDefinition'; -import resolveToValue from '../utils/resolveToValue'; +import isReactComponentClass from '../utils/isReactComponentClass.js'; +import isReactCreateClassCall from '../utils/isReactCreateClassCall.js'; +import isReactForwardRefCall from '../utils/isReactForwardRefCall.js'; +import isStatelessComponent from '../utils/isStatelessComponent.js'; +import normalizeClassDefinition from '../utils/normalizeClassDefinition.js'; +import resolveToValue from '../utils/resolveToValue.js'; import type { NodePath } from '@babel/traverse'; import { visitors } from '@babel/traverse'; -import type FileState from '../FileState'; -import type { ComponentNode, Resolver } from '.'; +import type FileState from '../FileState.js'; +import type { ComponentNode, Resolver } from './index.js'; import type { ArrowFunctionExpression, FunctionDeclaration, diff --git a/packages/react-docgen/src/resolver/findAllExportedComponentDefinitions.ts b/packages/react-docgen/src/resolver/findAllExportedComponentDefinitions.ts index 1581e0cbdef..f57b2c370ed 100644 --- a/packages/react-docgen/src/resolver/findAllExportedComponentDefinitions.ts +++ b/packages/react-docgen/src/resolver/findAllExportedComponentDefinitions.ts @@ -1,19 +1,19 @@ -import isExportsOrModuleAssignment from '../utils/isExportsOrModuleAssignment'; -import resolveExportDeclaration from '../utils/resolveExportDeclaration'; -import resolveToValue from '../utils/resolveToValue'; -import resolveHOC from '../utils/resolveHOC'; +import isExportsOrModuleAssignment from '../utils/isExportsOrModuleAssignment.js'; +import resolveExportDeclaration from '../utils/resolveExportDeclaration.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import resolveHOC from '../utils/resolveHOC.js'; import type { NodePath } from '@babel/traverse'; import { visitors } from '@babel/traverse'; -import { shallowIgnoreVisitors } from '../utils/traverse'; +import { shallowIgnoreVisitors } from '../utils/traverse.js'; import type { ExportDefaultDeclaration, ExportNamedDeclaration, } from '@babel/types'; -import type FileState from '../FileState'; -import type { ComponentNode, Resolver } from '.'; +import type FileState from '../FileState.js'; +import type { ComponentNode, Resolver } from './index.js'; import resolveComponentDefinition, { isComponentDefinition, -} from '../utils/resolveComponentDefinition'; +} from '../utils/resolveComponentDefinition.js'; interface TraverseState { foundDefinitions: Array>; diff --git a/packages/react-docgen/src/resolver/findExportedComponentDefinition.ts b/packages/react-docgen/src/resolver/findExportedComponentDefinition.ts index 24045565ac2..9a5adc6373b 100644 --- a/packages/react-docgen/src/resolver/findExportedComponentDefinition.ts +++ b/packages/react-docgen/src/resolver/findExportedComponentDefinition.ts @@ -1,19 +1,19 @@ -import isExportsOrModuleAssignment from '../utils/isExportsOrModuleAssignment'; -import resolveExportDeclaration from '../utils/resolveExportDeclaration'; -import resolveToValue from '../utils/resolveToValue'; -import resolveHOC from '../utils/resolveHOC'; +import isExportsOrModuleAssignment from '../utils/isExportsOrModuleAssignment.js'; +import resolveExportDeclaration from '../utils/resolveExportDeclaration.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import resolveHOC from '../utils/resolveHOC.js'; import type { NodePath } from '@babel/traverse'; import { visitors } from '@babel/traverse'; -import { shallowIgnoreVisitors } from '../utils/traverse'; +import { shallowIgnoreVisitors } from '../utils/traverse.js'; import type { ExportDefaultDeclaration, ExportNamedDeclaration, } from '@babel/types'; -import type { ComponentNode, Resolver } from '.'; -import type FileState from '../FileState'; +import type { ComponentNode, Resolver } from './index.js'; +import type FileState from '../FileState.js'; import resolveComponentDefinition, { isComponentDefinition, -} from '../utils/resolveComponentDefinition'; +} from '../utils/resolveComponentDefinition.js'; const ERROR_MULTIPLE_DEFINITIONS = 'Multiple exported component definitions found.'; diff --git a/packages/react-docgen/src/resolver/index.ts b/packages/react-docgen/src/resolver/index.ts index 9b92c2b46ac..2966317d1f2 100644 --- a/packages/react-docgen/src/resolver/index.ts +++ b/packages/react-docgen/src/resolver/index.ts @@ -1,8 +1,8 @@ -import findAllComponentDefinitions from './findAllComponentDefinitions'; -import findAllExportedComponentDefinitions from './findAllExportedComponentDefinitions'; -import findExportedComponentDefinition from './findExportedComponentDefinition'; +import findAllComponentDefinitions from './findAllComponentDefinitions.js'; +import findAllExportedComponentDefinitions from './findAllExportedComponentDefinitions.js'; +import findExportedComponentDefinition from './findExportedComponentDefinition.js'; import type { NodePath } from '@babel/traverse'; -import type FileState from '../FileState'; +import type FileState from '../FileState.js'; import type { ArrowFunctionExpression, CallExpression, diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/getClassMemberValuePath-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/getClassMemberValuePath-test.ts.snap index d6f0c31a29a..0dc91ab1370 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/getClassMemberValuePath-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/getClassMemberValuePath-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`getClassMemberValuePath ClassDeclaration Getters and Setters finds getters 1`] = ` +exports[`getClassMemberValuePath > ClassDeclaration > Getters and Setters > finds getters 1`] = ` Node { "async": false, "body": Node { @@ -22,7 +22,7 @@ Node { } `; -exports[`getClassMemberValuePath ClassDeclaration MethodDefinitions finds "normal" method definitions 1`] = ` +exports[`getClassMemberValuePath > ClassDeclaration > MethodDefinitions > finds "normal" method definitions 1`] = ` Node { "async": false, "body": Node { @@ -44,7 +44,7 @@ Node { } `; -exports[`getClassMemberValuePath ClassDeclaration MethodDefinitions finds computed method definitions with literal keys 1`] = ` +exports[`getClassMemberValuePath > ClassDeclaration > MethodDefinitions > finds computed method definitions with literal keys 1`] = ` Node { "async": false, "body": Node { @@ -70,7 +70,7 @@ Node { } `; -exports[`getClassMemberValuePath ClassExpression finds "normal" method definitions 1`] = ` +exports[`getClassMemberValuePath > ClassExpression > finds "normal" method definitions 1`] = ` Node { "async": false, "body": Node { diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/getFlowType-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/getFlowType-test.ts.snap index 3759d219210..b1f5ad1dd88 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/getFlowType-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/getFlowType-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`getFlowType handles ObjectTypeSpreadProperty 1`] = ` +exports[`getFlowType > handles ObjectTypeSpreadProperty 1`] = ` { "name": "signature", "raw": "{| apple: string, banana: string, ...OtherFruits |}", @@ -33,7 +33,7 @@ exports[`getFlowType handles ObjectTypeSpreadProperty 1`] = ` } `; -exports[`getFlowType handles ObjectTypeSpreadProperty from imported types 1`] = ` +exports[`getFlowType > handles ObjectTypeSpreadProperty from imported types 1`] = ` { "name": "signature", "raw": "{| apple: string, banana: string, ...MyType |}", @@ -74,7 +74,7 @@ exports[`getFlowType handles ObjectTypeSpreadProperty from imported types 1`] = } `; -exports[`getFlowType handles nested ObjectTypeSpreadProperty 1`] = ` +exports[`getFlowType > handles nested ObjectTypeSpreadProperty 1`] = ` { "name": "signature", "raw": "{| apple: string, banana: string, ...BreakfastFruits |}", @@ -121,7 +121,7 @@ exports[`getFlowType handles nested ObjectTypeSpreadProperty 1`] = ` } `; -exports[`getFlowType handles unresolved ObjectTypeSpreadProperty 1`] = ` +exports[`getFlowType > handles unresolved ObjectTypeSpreadProperty 1`] = ` { "name": "signature", "raw": "{| apple: string, banana: string, ...MyType |}", diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/getMemberExpressionRoot-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/getMemberExpressionRoot-test.ts.snap new file mode 100644 index 00000000000..6ff7b0fbeee --- /dev/null +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/getMemberExpressionRoot-test.ts.snap @@ -0,0 +1,32 @@ +// Vitest Snapshot v1 + +exports[`getMemberExpressionRoot > returns the root of a member expression 1`] = ` +Node { + "name": "foo", + "type": "Identifier", +} +`; + +exports[`getMemberExpressionRoot > returns the same path if identifier 1`] = ` +Node { + "extra": { + "parenStart": 0, + "parenthesized": true, + }, + "name": "foo", + "type": "Identifier", +} +`; + +exports[`getMemberExpressionRoot > returns the same path if literal 1`] = ` +Node { + "extra": { + "parenStart": 0, + "parenthesized": true, + "raw": "1", + "rawValue": 1, + }, + "type": "NumericLiteral", + "value": 1, +} +`; diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/getMembers-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/getMembers-test.ts.snap index 7c9d1c01f02..24d30a44e4b 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/getMembers-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/getMembers-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`getMembers does work with custom expressions in arguments 1`] = ` +exports[`getMembers > does work with custom expressions in arguments 1`] = ` [ { "argumentPaths": [ @@ -36,7 +36,7 @@ exports[`getMembers does work with custom expressions in arguments 1`] = ` "computed": true, "path": Node { "extra": { - "raw": ""baz"", + "raw": "\\"baz\\"", "rawValue": "baz", }, "type": "StringLiteral", @@ -46,7 +46,7 @@ exports[`getMembers does work with custom expressions in arguments 1`] = ` ] `; -exports[`getMembers does work with custom expressions in chain 1`] = ` +exports[`getMembers > does work with custom expressions in chain 1`] = ` [ { "argumentPaths": [ @@ -71,7 +71,7 @@ exports[`getMembers does work with custom expressions in chain 1`] = ` "path": Node { "left": Node { "extra": { - "raw": """", + "raw": "\\"\\"", "rawValue": "", }, "type": "StringLiteral", @@ -80,7 +80,7 @@ exports[`getMembers does work with custom expressions in chain 1`] = ` "operator": "+", "right": Node { "extra": { - "raw": """", + "raw": "\\"\\"", "rawValue": "", }, "type": "StringLiteral", @@ -92,7 +92,7 @@ exports[`getMembers does work with custom expressions in chain 1`] = ` ] `; -exports[`getMembers finds all "members" "inside" a MemberExpression 1`] = ` +exports[`getMembers > finds all "members" "inside" a MemberExpression 1`] = ` [ { "argumentPaths": [ @@ -134,7 +134,7 @@ exports[`getMembers finds all "members" "inside" a MemberExpression 1`] = ` ] `; -exports[`getMembers includes the root if option set to true 1`] = ` +exports[`getMembers > includes the root if option set to true 1`] = ` [ { "argumentPaths": [], diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/getMethodDocumentation-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/getMethodDocumentation-test.ts.snap index be9b55f48a2..4b7d2394d57 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/getMethodDocumentation-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/getMethodDocumentation-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`getMethodDocumentation name handles computed method name 1`] = ` +exports[`getMethodDocumentation > name > handles computed method name 1`] = ` { "docblock": null, "modifiers": [], @@ -10,9 +10,9 @@ exports[`getMethodDocumentation name handles computed method name 1`] = ` } `; -exports[`getMethodDocumentation name ignores complex computed method name 1`] = `null`; +exports[`getMethodDocumentation > name > ignores complex computed method name 1`] = `null`; -exports[`getMethodDocumentation parameters does not add type parameters to alias 1`] = ` +exports[`getMethodDocumentation > parameters > does not add type parameters to alias 1`] = ` { "docblock": null, "modifiers": [], @@ -37,7 +37,7 @@ exports[`getMethodDocumentation parameters does not add type parameters to alias } `; -exports[`getMethodDocumentation parameters extracts flow type info 1`] = ` +exports[`getMethodDocumentation > parameters > extracts flow type info 1`] = ` { "docblock": null, "modifiers": [], @@ -55,7 +55,7 @@ exports[`getMethodDocumentation parameters extracts flow type info 1`] = ` } `; -exports[`getMethodDocumentation parameters extracts flow type info 2`] = ` +exports[`getMethodDocumentation > parameters > extracts flow type info 2`] = ` { "docblock": null, "modifiers": [], @@ -73,7 +73,7 @@ exports[`getMethodDocumentation parameters extracts flow type info 2`] = ` } `; -exports[`getMethodDocumentation parameters extracts flow type info on function assignment 1`] = ` +exports[`getMethodDocumentation > parameters > extracts flow type info on function assignment 1`] = ` { "docblock": null, "modifiers": [], @@ -91,11 +91,11 @@ exports[`getMethodDocumentation parameters extracts flow type info on function a } `; -exports[`getMethodDocumentation parameters private ignores private methods 1`] = `null`; +exports[`getMethodDocumentation > parameters > private > ignores private methods 1`] = `null`; -exports[`getMethodDocumentation parameters private ignores private typescript methods 1`] = `null`; +exports[`getMethodDocumentation > parameters > private > ignores private typescript methods 1`] = `null`; -exports[`getMethodDocumentation parameters resolves flow type info on imported functions 1`] = ` +exports[`getMethodDocumentation > parameters > resolves flow type info on imported functions 1`] = ` { "docblock": null, "modifiers": [], diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/getNameOrValue-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/getNameOrValue-test.ts.snap index ba485873a51..f91884e6664 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/getNameOrValue-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/getNameOrValue-test.ts.snap @@ -1,19 +1,19 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`getNameOrValue errors on invalid path 1`] = `"Argument must be Identifier, Literal, QualifiedTypeIdentifier or TSQualifiedName. Received 'FunctionDeclaration'"`; +exports[`getNameOrValue > errors on invalid path 1`] = `"Argument must be Identifier, Literal, QualifiedTypeIdentifier or TSQualifiedName. Received 'FunctionDeclaration'"`; -exports[`getNameOrValue gets Identifier name 1`] = `"foo"`; +exports[`getNameOrValue > gets Identifier name 1`] = `"foo"`; -exports[`getNameOrValue gets QualifiedTypeIdentifier 1`] = `"x.h"`; +exports[`getNameOrValue > gets QualifiedTypeIdentifier 1`] = `"x.h"`; -exports[`getNameOrValue gets TSQualifiedName 1`] = `"x.h"`; +exports[`getNameOrValue > gets TSQualifiedName 1`] = `"x.h"`; -exports[`getNameOrValue gets boolean literal value 1`] = `true`; +exports[`getNameOrValue > gets boolean literal value 1`] = `true`; -exports[`getNameOrValue gets null RegExp pattern 1`] = `"abc?"`; +exports[`getNameOrValue > gets null RegExp pattern 1`] = `"abc?"`; -exports[`getNameOrValue gets null literal value 1`] = `null`; +exports[`getNameOrValue > gets null literal value 1`] = `null`; -exports[`getNameOrValue gets numeric literal value 1`] = `1`; +exports[`getNameOrValue > gets numeric literal value 1`] = `1`; -exports[`getNameOrValue gets string literal value 1`] = `"foo"`; +exports[`getNameOrValue > gets string literal value 1`] = `"foo"`; diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/getPropType-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/getPropType-test.ts.snap index b4909bdc760..166f0e7eb94 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/getPropType-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/getPropType-test.ts.snap @@ -1,20 +1,20 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`getPropType detects custom validation functions for arrow function 1`] = ` +exports[`getPropType > detects custom validation functions for arrow function 1`] = ` { "name": "custom", "raw": "() => {}", } `; -exports[`getPropType detects custom validation functions for function 1`] = ` +exports[`getPropType > detects custom validation functions for function 1`] = ` { "name": "custom", "raw": "function() {}", } `; -exports[`getPropType detects descriptions on nested types in arrayOf 1`] = ` +exports[`getPropType > detects descriptions on nested types in arrayOf 1`] = ` { "description": "test2", "name": "arrayOf", @@ -24,7 +24,7 @@ exports[`getPropType detects descriptions on nested types in arrayOf 1`] = ` } `; -exports[`getPropType detects descriptions on nested types in exacts 1`] = ` +exports[`getPropType > detects descriptions on nested types in exacts 1`] = ` { "name": "exact", "value": { @@ -42,7 +42,7 @@ exports[`getPropType detects descriptions on nested types in exacts 1`] = ` } `; -exports[`getPropType detects descriptions on nested types in objectOf 1`] = ` +exports[`getPropType > detects descriptions on nested types in objectOf 1`] = ` { "description": "test2", "name": "objectOf", @@ -52,7 +52,7 @@ exports[`getPropType detects descriptions on nested types in objectOf 1`] = ` } `; -exports[`getPropType detects descriptions on nested types in shapes 1`] = ` +exports[`getPropType > detects descriptions on nested types in shapes 1`] = ` { "name": "shape", "value": { @@ -70,7 +70,7 @@ exports[`getPropType detects descriptions on nested types in shapes 1`] = ` } `; -exports[`getPropType detects required notations of nested types in exacts 1`] = ` +exports[`getPropType > detects required notations of nested types in exacts 1`] = ` { "name": "exact", "value": { @@ -86,7 +86,7 @@ exports[`getPropType detects required notations of nested types in exacts 1`] = } `; -exports[`getPropType detects required notations of nested types in shapes 1`] = ` +exports[`getPropType > detects required notations of nested types in shapes 1`] = ` { "name": "shape", "value": { @@ -102,7 +102,7 @@ exports[`getPropType detects required notations of nested types in shapes 1`] = } `; -exports[`getPropType handles computed properties 1`] = ` +exports[`getPropType > handles computed properties 1`] = ` { "name": "exact", "value": { @@ -118,7 +118,7 @@ exports[`getPropType handles computed properties 1`] = ` } `; -exports[`getPropType ignores complex computed properties 1`] = ` +exports[`getPropType > ignores complex computed properties 1`] = ` { "name": "exact", "value": { @@ -130,55 +130,55 @@ exports[`getPropType ignores complex computed properties 1`] = ` } `; -exports[`getPropType resolve identifier to their values correctly resolves SpreadElements in arrays 1`] = ` +exports[`getPropType > resolve identifier to their values > correctly resolves SpreadElements in arrays 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values correctly resolves SpreadElements in arrays from imported values 1`] = ` +exports[`getPropType > resolve identifier to their values > correctly resolves SpreadElements in arrays from imported values 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values correctly resolves nested SpreadElements in arrays 1`] = ` +exports[`getPropType > resolve identifier to their values > correctly resolves nested SpreadElements in arrays 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values does not resolve external values without proper importer 1`] = ` +exports[`getPropType > resolve identifier to their values > does not resolve external values without proper importer 1`] = ` { "computed": true, "name": "enum", @@ -186,55 +186,55 @@ exports[`getPropType resolve identifier to their values does not resolve externa } `; -exports[`getPropType resolve identifier to their values does resolve object keys values 1`] = ` +exports[`getPropType > resolve identifier to their values > does resolve object keys values 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""FOO"", + "value": "\\"FOO\\"", }, { "computed": false, - "value": ""BAR"", + "value": "\\"BAR\\"", }, ], } `; -exports[`getPropType resolve identifier to their values does resolve object values 1`] = ` +exports[`getPropType > resolve identifier to their values > does resolve object values 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values resolves imported identifier to their initialization value in array 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves imported identifier to their initialization value in array 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values resolves imported variables to their values 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves imported variables to their values 1`] = ` { "name": "shape", "value": { @@ -246,119 +246,119 @@ exports[`getPropType resolve identifier to their values resolves imported variab } `; -exports[`getPropType resolve identifier to their values resolves importer identifier to initialization value 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves importer identifier to initialization value 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values resolves memberExpressions 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves memberExpressions 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values resolves memberExpressions from imported objects 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves memberExpressions from imported objects 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values resolves simple identifier to their initialization value 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves simple identifier to their initialization value 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values resolves simple identifier to their initialization value in array 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves simple identifier to their initialization value in array 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values resolves values from imported Object.keys call 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves values from imported Object.keys call 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""FOO"", + "value": "\\"FOO\\"", }, { "computed": false, - "value": ""BAR"", + "value": "\\"BAR\\"", }, ], } `; -exports[`getPropType resolve identifier to their values resolves values from imported Object.values call 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves values from imported Object.values call 1`] = ` { "name": "enum", "value": [ { "computed": false, - "value": ""foo"", + "value": "\\"foo\\"", }, { "computed": false, - "value": ""bar"", + "value": "\\"bar\\"", }, ], } `; -exports[`getPropType resolve identifier to their values resolves variables to their values 1`] = ` +exports[`getPropType > resolve identifier to their values > resolves variables to their values 1`] = ` { "name": "shape", "value": { diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/getTSType-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/getTSType-test.ts.snap index 3ba4b824434..5e2c221eded 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/getTSType-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/getTSType-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`getTSType React types React.ChildrenArray 1`] = ` +exports[`getTSType > React types > React.ChildrenArray 1`] = ` { "elements": [ { @@ -12,7 +12,7 @@ exports[`getTSType React types React.ChildrenArray 1`] = ` } `; -exports[`getTSType React types React.ComponentType 1`] = ` +exports[`getTSType > React types > React.ComponentType 1`] = ` { "elements": [ { @@ -37,7 +37,7 @@ exports[`getTSType React types React.ComponentType 1`] = ` } `; -exports[`getTSType React types React.Element 1`] = ` +exports[`getTSType > React types > React.Element 1`] = ` { "elements": [ { @@ -49,7 +49,7 @@ exports[`getTSType React types React.Element 1`] = ` } `; -exports[`getTSType React types React.ElementProps 1`] = ` +exports[`getTSType > React types > React.ElementProps 1`] = ` { "elements": [ { @@ -61,7 +61,7 @@ exports[`getTSType React types React.ElementProps 1`] = ` } `; -exports[`getTSType React types React.ElementRef 1`] = ` +exports[`getTSType > React types > React.ElementRef 1`] = ` { "elements": [ { @@ -73,28 +73,28 @@ exports[`getTSType React types React.ElementRef 1`] = ` } `; -exports[`getTSType React types React.ElementType 1`] = ` +exports[`getTSType > React types > React.ElementType 1`] = ` { "name": "ReactElementType", "raw": "React.ElementType", } `; -exports[`getTSType React types React.Key 1`] = ` +exports[`getTSType > React types > React.Key 1`] = ` { "name": "ReactKey", "raw": "React.Key", } `; -exports[`getTSType React types React.Node 1`] = ` +exports[`getTSType > React types > React.Node 1`] = ` { "name": "ReactNode", "raw": "React.Node", } `; -exports[`getTSType React types React.Ref 1`] = ` +exports[`getTSType > React types > React.Ref 1`] = ` { "elements": [ { @@ -106,7 +106,7 @@ exports[`getTSType React types React.Ref 1`] = ` } `; -exports[`getTSType React types React.StatelessFunctionalComponent 1`] = ` +exports[`getTSType > React types > React.StatelessFunctionalComponent 1`] = ` { "elements": [ { @@ -118,14 +118,14 @@ exports[`getTSType React types React.StatelessFunctionalComponent 1`] = } `; -exports[`getTSType can resolve indexed access to imported type 1`] = ` +exports[`getTSType > can resolve indexed access to imported type 1`] = ` { "name": "string", - "raw": "A["x"]", + "raw": "A[\\"x\\"]", } `; -exports[`getTSType detects array type 1`] = ` +exports[`getTSType > detects array type 1`] = ` { "elements": [ { @@ -137,7 +137,7 @@ exports[`getTSType detects array type 1`] = ` } `; -exports[`getTSType detects array type shorthand 1`] = ` +exports[`getTSType > detects array type shorthand 1`] = ` { "elements": [ { @@ -149,7 +149,7 @@ exports[`getTSType detects array type shorthand 1`] = ` } `; -exports[`getTSType detects array type with multiple types 1`] = ` +exports[`getTSType > detects array type with multiple types 1`] = ` { "elements": [ { @@ -164,7 +164,7 @@ exports[`getTSType detects array type with multiple types 1`] = ` } `; -exports[`getTSType detects callable signature type 1`] = ` +exports[`getTSType > detects callable signature type 1`] = ` { "name": "signature", "raw": "{ (str: string): string, token: string }", @@ -201,7 +201,7 @@ exports[`getTSType detects callable signature type 1`] = ` } `; -exports[`getTSType detects class type 1`] = ` +exports[`getTSType > detects class type 1`] = ` { "elements": [ { @@ -213,13 +213,13 @@ exports[`getTSType detects class type 1`] = ` } `; -exports[`getTSType detects external type 1`] = ` +exports[`getTSType > detects external type 1`] = ` { "name": "xyz", } `; -exports[`getTSType detects function signature type 1`] = ` +exports[`getTSType > detects function signature type 1`] = ` { "name": "signature", "raw": "(p1: number, p2: string, ...rest: Array) => boolean", @@ -259,7 +259,7 @@ exports[`getTSType detects function signature type 1`] = ` } `; -exports[`getTSType detects function signature type with \`this\` parameter 1`] = ` +exports[`getTSType > detects function signature type with \`this\` parameter 1`] = ` { "name": "signature", "raw": "(this: Foo, p1: number) => boolean", @@ -283,7 +283,7 @@ exports[`getTSType detects function signature type with \`this\` parameter 1`] = } `; -exports[`getTSType detects function type with subtype 1`] = ` +exports[`getTSType > detects function type with subtype 1`] = ` { "elements": [ { @@ -295,14 +295,14 @@ exports[`getTSType detects function type with subtype 1`] = ` } `; -exports[`getTSType detects indexed access 1`] = ` +exports[`getTSType > detects indexed access 1`] = ` { - "name": "A["x"]", - "raw": "A["x"]", + "name": "A[\\"x\\"]", + "raw": "A[\\"x\\"]", } `; -exports[`getTSType detects intersection type 1`] = ` +exports[`getTSType > detects intersection type 1`] = ` { "elements": [ { @@ -313,21 +313,21 @@ exports[`getTSType detects intersection type 1`] = ` }, { "name": "literal", - "value": ""foo"", + "value": "\\"foo\\"", }, { "name": "void", }, ], "name": "intersection", - "raw": "string & xyz & "foo" & void", + "raw": "string & xyz & \\"foo\\" & void", } `; -exports[`getTSType detects map signature 1`] = ` +exports[`getTSType > detects map signature 1`] = ` { "name": "signature", - "raw": "{ [key: string]: number, [key: "xl"]: string, token: "a" | "b" }", + "raw": "{ [key: string]: number, [key: \\"xl\\"]: string, token: \\"a\\" | \\"b\\" }", "signature": { "properties": [ { @@ -342,7 +342,7 @@ exports[`getTSType detects map signature 1`] = ` { "key": { "name": "literal", - "value": ""xl"", + "value": "\\"xl\\"", }, "value": { "name": "string", @@ -355,15 +355,15 @@ exports[`getTSType detects map signature 1`] = ` "elements": [ { "name": "literal", - "value": ""a"", + "value": "\\"a\\"", }, { "name": "literal", - "value": ""b"", + "value": "\\"b\\"", }, ], "name": "union", - "raw": ""a" | "b"", + "raw": "\\"a\\" | \\"b\\"", "required": true, }, }, @@ -373,7 +373,7 @@ exports[`getTSType detects map signature 1`] = ` } `; -exports[`getTSType detects object types 1`] = ` +exports[`getTSType > detects object types 1`] = ` { "name": "signature", "raw": "{ a: string, b?: xyz }", @@ -399,97 +399,97 @@ exports[`getTSType detects object types 1`] = ` } `; -exports[`getTSType detects simple types 1`] = ` +exports[`getTSType > detects simple types 1`] = ` { "name": "string", } `; -exports[`getTSType detects simple types 2`] = ` +exports[`getTSType > detects simple types 2`] = ` { "name": "number", } `; -exports[`getTSType detects simple types 3`] = ` +exports[`getTSType > detects simple types 3`] = ` { "name": "boolean", } `; -exports[`getTSType detects simple types 4`] = ` +exports[`getTSType > detects simple types 4`] = ` { "name": "symbol", } `; -exports[`getTSType detects simple types 5`] = ` +exports[`getTSType > detects simple types 5`] = ` { "name": "object", } `; -exports[`getTSType detects simple types 6`] = ` +exports[`getTSType > detects simple types 6`] = ` { "name": "any", } `; -exports[`getTSType detects simple types 7`] = ` +exports[`getTSType > detects simple types 7`] = ` { "name": "unknown", } `; -exports[`getTSType detects simple types 8`] = ` +exports[`getTSType > detects simple types 8`] = ` { "name": "null", } `; -exports[`getTSType detects simple types 9`] = ` +exports[`getTSType > detects simple types 9`] = ` { "name": "undefined", } `; -exports[`getTSType detects simple types 10`] = ` +exports[`getTSType > detects simple types 10`] = ` { "name": "void", } `; -exports[`getTSType detects simple types 11`] = ` +exports[`getTSType > detects simple types 11`] = ` { "name": "Object", } `; -exports[`getTSType detects simple types 12`] = ` +exports[`getTSType > detects simple types 12`] = ` { "name": "Function", } `; -exports[`getTSType detects simple types 13`] = ` +exports[`getTSType > detects simple types 13`] = ` { "name": "Boolean", } `; -exports[`getTSType detects simple types 14`] = ` +exports[`getTSType > detects simple types 14`] = ` { "name": "String", } `; -exports[`getTSType detects simple types 15`] = ` +exports[`getTSType > detects simple types 15`] = ` { "name": "Number", } `; -exports[`getTSType detects tuple in union signature 1`] = ` +exports[`getTSType > detects tuple in union signature 1`] = ` { "elements": [ { @@ -522,7 +522,7 @@ exports[`getTSType detects tuple in union signature 1`] = ` } `; -exports[`getTSType detects tuple signature 1`] = ` +exports[`getTSType > detects tuple signature 1`] = ` { "elements": [ { @@ -537,7 +537,7 @@ exports[`getTSType detects tuple signature 1`] = ` } `; -exports[`getTSType detects union type 1`] = ` +exports[`getTSType > detects union type 1`] = ` { "elements": [ { @@ -548,18 +548,18 @@ exports[`getTSType detects union type 1`] = ` }, { "name": "literal", - "value": ""foo"", + "value": "\\"foo\\"", }, { "name": "void", }, ], "name": "union", - "raw": "string | xyz | "foo" | void", + "raw": "string | xyz | \\"foo\\" | void", } `; -exports[`getTSType handles generic types 1`] = ` +exports[`getTSType > handles generic types 1`] = ` { "name": "signature", "raw": "{ a: T, b: Array }", @@ -591,7 +591,7 @@ exports[`getTSType handles generic types 1`] = ` } `; -exports[`getTSType handles generics of the same Name 1`] = ` +exports[`getTSType > handles generics of the same Name 1`] = ` { "elements": [ { @@ -603,7 +603,7 @@ exports[`getTSType handles generics of the same Name 1`] = ` } `; -exports[`getTSType handles long type cycles 1`] = ` +exports[`getTSType > handles long type cycles 1`] = ` { "name": "signature", "raw": "{ subAction: SubAction }", @@ -661,7 +661,7 @@ exports[`getTSType handles long type cycles 1`] = ` } `; -exports[`getTSType handles mapped types 1`] = ` +exports[`getTSType > handles mapped types 1`] = ` { "name": "signature", "raw": "{ [key in 'x' | 'y']: boolean}", @@ -693,7 +693,7 @@ exports[`getTSType handles mapped types 1`] = ` } `; -exports[`getTSType handles multiple references to one type 1`] = ` +exports[`getTSType > handles multiple references to one type 1`] = ` { "name": "signature", "raw": "{ a: Action, b: Action }", @@ -729,13 +729,13 @@ exports[`getTSType handles multiple references to one type 1`] = ` } `; -exports[`getTSType handles qualified type identifiers 1`] = ` +exports[`getTSType > handles qualified type identifiers 1`] = ` { "name": "MyType.x", } `; -exports[`getTSType handles qualified type identifiers with params 1`] = ` +exports[`getTSType > handles qualified type identifiers with params 1`] = ` { "elements": [ { @@ -747,7 +747,7 @@ exports[`getTSType handles qualified type identifiers with params 1`] = ` } `; -exports[`getTSType handles self-referencing type cycles 1`] = ` +exports[`getTSType > handles self-referencing type cycles 1`] = ` { "name": "signature", "raw": "{ subAction: Action }", @@ -766,7 +766,7 @@ exports[`getTSType handles self-referencing type cycles 1`] = ` } `; -exports[`getTSType handles typeof types 1`] = ` +exports[`getTSType > handles typeof types 1`] = ` { "name": "signature", "raw": "{ a: string, b: xyz }", @@ -792,48 +792,48 @@ exports[`getTSType handles typeof types 1`] = ` } `; -exports[`getTSType literal types detects "foo" 1`] = ` +exports[`getTSType > literal types > detects "foo" 1`] = ` { "name": "literal", - "value": ""foo"", + "value": "\\"foo\\"", } `; -exports[`getTSType literal types detects \`foo\` 1`] = ` +exports[`getTSType > literal types > detects \`foo\` 1`] = ` { "name": "literal", "value": "\`foo\`", } `; -exports[`getTSType literal types detects -1 1`] = ` +exports[`getTSType > literal types > detects -1 1`] = ` { "name": "literal", "value": "-1", } `; -exports[`getTSType literal types detects 1234 1`] = ` +exports[`getTSType > literal types > detects 1234 1`] = ` { "name": "literal", "value": "1234", } `; -exports[`getTSType literal types detects true 1`] = ` +exports[`getTSType > literal types > detects true 1`] = ` { "name": "literal", "value": "true", } `; -exports[`getTSType resolves external type 1`] = ` +exports[`getTSType > resolves external type 1`] = ` { "name": "string", } `; -exports[`getTSType resolves function signature types with imported types 1`] = ` +exports[`getTSType > resolves function signature types with imported types 1`] = ` { "name": "signature", "raw": "(p1: abc, p2: xyz, ...rest: Array) => def", @@ -873,7 +873,7 @@ exports[`getTSType resolves function signature types with imported types 1`] = ` } `; -exports[`getTSType resolves function signature types with imported types 2`] = ` +exports[`getTSType > resolves function signature types with imported types 2`] = ` { "name": "signature", "raw": "(this: xyz, p1: number) => boolean", @@ -897,7 +897,7 @@ exports[`getTSType resolves function signature types with imported types 2`] = ` } `; -exports[`getTSType resolves function signature types with imported types 3`] = ` +exports[`getTSType > resolves function signature types with imported types 3`] = ` { "name": "signature", "raw": "{ (str: xyz): abc, token: def }", @@ -934,7 +934,7 @@ exports[`getTSType resolves function signature types with imported types 3`] = ` } `; -exports[`getTSType resolves imported subtype for class type 1`] = ` +exports[`getTSType > resolves imported subtype for class type 1`] = ` { "elements": [ { @@ -946,7 +946,7 @@ exports[`getTSType resolves imported subtype for class type 1`] = ` } `; -exports[`getTSType resolves imported subtype for function type 1`] = ` +exports[`getTSType > resolves imported subtype for function type 1`] = ` { "elements": [ { @@ -958,7 +958,7 @@ exports[`getTSType resolves imported subtype for function type 1`] = ` } `; -exports[`getTSType resolves imported types applied to mapped types 1`] = ` +exports[`getTSType > resolves imported types applied to mapped types 1`] = ` { "name": "signature", "raw": "{ [key in barbaz]: boolean}", @@ -969,15 +969,15 @@ exports[`getTSType resolves imported types applied to mapped types 1`] = ` "elements": [ { "name": "literal", - "value": ""bar"", + "value": "\\"bar\\"", }, { "name": "literal", - "value": ""baz"", + "value": "\\"baz\\"", }, ], "name": "union", - "raw": ""bar" | "baz"", + "raw": "\\"bar\\" | \\"baz\\"", "required": true, }, "value": { @@ -990,7 +990,7 @@ exports[`getTSType resolves imported types applied to mapped types 1`] = ` } `; -exports[`getTSType resolves imported types for object property types 1`] = ` +exports[`getTSType > resolves imported types for object property types 1`] = ` { "name": "signature", "raw": "{ a: number, b?: xyz }", @@ -1016,10 +1016,10 @@ exports[`getTSType resolves imported types for object property types 1`] = ` } `; -exports[`getTSType resolves imported types in map signature 1`] = ` +exports[`getTSType > resolves imported types in map signature 1`] = ` { "name": "signature", - "raw": "{ [key: xyz]: abc, [key: "xl"]: xyz, token: barbaz }", + "raw": "{ [key: xyz]: abc, [key: \\"xl\\"]: xyz, token: barbaz }", "signature": { "properties": [ { @@ -1035,7 +1035,7 @@ exports[`getTSType resolves imported types in map signature 1`] = ` { "key": { "name": "literal", - "value": ""xl"", + "value": "\\"xl\\"", }, "value": { "name": "string", @@ -1048,15 +1048,15 @@ exports[`getTSType resolves imported types in map signature 1`] = ` "elements": [ { "name": "literal", - "value": ""bar"", + "value": "\\"bar\\"", }, { "name": "literal", - "value": ""baz"", + "value": "\\"baz\\"", }, ], "name": "union", - "raw": ""bar" | "baz"", + "raw": "\\"bar\\" | \\"baz\\"", "required": true, }, }, @@ -1066,7 +1066,7 @@ exports[`getTSType resolves imported types in map signature 1`] = ` } `; -exports[`getTSType resolves imported types in tuple signatures 1`] = ` +exports[`getTSType > resolves imported types in tuple signatures 1`] = ` { "elements": [ { @@ -1081,7 +1081,7 @@ exports[`getTSType resolves imported types in tuple signatures 1`] = ` } `; -exports[`getTSType resolves imported types in tuple signatures 2`] = ` +exports[`getTSType > resolves imported types in tuple signatures 2`] = ` { "elements": [ { @@ -1114,7 +1114,7 @@ exports[`getTSType resolves imported types in tuple signatures 2`] = ` } `; -exports[`getTSType resolves imported types that need subtypes 1`] = ` +exports[`getTSType > resolves imported types that need subtypes 1`] = ` { "name": "signature", "raw": "{ a: T, b: Array }", @@ -1146,7 +1146,7 @@ exports[`getTSType resolves imported types that need subtypes 1`] = ` } `; -exports[`getTSType resolves imported types used for arrays 1`] = ` +exports[`getTSType > resolves imported types used for arrays 1`] = ` { "elements": [ { @@ -1158,7 +1158,7 @@ exports[`getTSType resolves imported types used for arrays 1`] = ` } `; -exports[`getTSType resolves imported types used for arrays 2`] = ` +exports[`getTSType > resolves imported types used for arrays 2`] = ` { "elements": [ { @@ -1170,7 +1170,7 @@ exports[`getTSType resolves imported types used for arrays 2`] = ` } `; -exports[`getTSType resolves imported types used for arrays 3`] = ` +exports[`getTSType > resolves imported types used for arrays 3`] = ` { "elements": [ { @@ -1185,7 +1185,7 @@ exports[`getTSType resolves imported types used for arrays 3`] = ` } `; -exports[`getTSType resolves imported types within intersection type 1`] = ` +exports[`getTSType > resolves imported types within intersection type 1`] = ` { "elements": [ { @@ -1195,30 +1195,30 @@ exports[`getTSType resolves imported types within intersection type 1`] = ` "elements": [ { "name": "literal", - "value": ""bar"", + "value": "\\"bar\\"", }, { "name": "literal", - "value": ""baz"", + "value": "\\"baz\\"", }, ], "name": "union", - "raw": ""bar" | "baz"", + "raw": "\\"bar\\" | \\"baz\\"", }, { "name": "literal", - "value": ""foo"", + "value": "\\"foo\\"", }, { "name": "void", }, ], "name": "intersection", - "raw": "string & barbaz & "foo" & void", + "raw": "string & barbaz & \\"foo\\" & void", } `; -exports[`getTSType resolves imported types within union type 1`] = ` +exports[`getTSType > resolves imported types within union type 1`] = ` { "elements": [ { @@ -1228,44 +1228,44 @@ exports[`getTSType resolves imported types within union type 1`] = ` "elements": [ { "name": "literal", - "value": ""bar"", + "value": "\\"bar\\"", }, { "name": "literal", - "value": ""baz"", + "value": "\\"baz\\"", }, ], "name": "union", - "raw": ""bar" | "baz"", + "raw": "\\"bar\\" | \\"baz\\"", }, { "name": "literal", - "value": ""foo"", + "value": "\\"foo\\"", }, { "name": "void", }, ], "name": "union", - "raw": "string | barbaz | "foo" | void", + "raw": "string | barbaz | \\"foo\\" | void", } `; -exports[`getTSType resolves indexed access 1`] = ` +exports[`getTSType > resolves indexed access 1`] = ` { "name": "string", - "raw": "A["x"]", + "raw": "A[\\"x\\"]", } `; -exports[`getTSType resolves indexed access of array 1`] = ` +exports[`getTSType > resolves indexed access of array 1`] = ` { "name": "STRING_VALS[number]", "raw": "typeof STRING_VALS[number]", } `; -exports[`getTSType resolves keyof to union 1`] = ` +exports[`getTSType > resolves keyof to union 1`] = ` { "elements": [ { @@ -1282,7 +1282,7 @@ exports[`getTSType resolves keyof to union 1`] = ` } `; -exports[`getTSType resolves keyof with imported types 1`] = ` +exports[`getTSType > resolves keyof with imported types 1`] = ` { "elements": [ { @@ -1299,7 +1299,7 @@ exports[`getTSType resolves keyof with imported types 1`] = ` } `; -exports[`getTSType resolves keyof with inline object to union 1`] = ` +exports[`getTSType > resolves keyof with inline object to union 1`] = ` { "elements": [ { @@ -1316,7 +1316,7 @@ exports[`getTSType resolves keyof with inline object to union 1`] = ` } `; -exports[`getTSType resolves typeof of imported types 1`] = ` +exports[`getTSType > resolves typeof of imported types 1`] = ` { "name": "signature", "raw": "{ a: number, b: xyz }", @@ -1342,7 +1342,7 @@ exports[`getTSType resolves typeof of imported types 1`] = ` } `; -exports[`getTSType resolves types in scope 1`] = ` +exports[`getTSType > resolves types in scope 1`] = ` { "name": "string", } diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/parseJsDoc-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/parseJsDoc-test.ts.snap index 260e82e673f..91da1e6a614 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/parseJsDoc-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/parseJsDoc-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`parseJsDoc @param extracts jsdoc description 1`] = ` +exports[`parseJsDoc > @param > extracts jsdoc description 1`] = ` { "description": null, "params": [ @@ -15,7 +15,7 @@ exports[`parseJsDoc @param extracts jsdoc description 1`] = ` } `; -exports[`parseJsDoc @param extracts jsdoc empty description 1`] = ` +exports[`parseJsDoc > @param > extracts jsdoc empty description 1`] = ` { "description": null, "params": [ @@ -32,7 +32,7 @@ exports[`parseJsDoc @param extracts jsdoc empty description 1`] = ` } `; -exports[`parseJsDoc @param extracts jsdoc optional 1`] = ` +exports[`parseJsDoc > @param > extracts jsdoc optional 1`] = ` { "description": null, "params": [ @@ -49,7 +49,7 @@ exports[`parseJsDoc @param extracts jsdoc optional 1`] = ` } `; -exports[`parseJsDoc @param extracts jsdoc typed array 1`] = ` +exports[`parseJsDoc > @param > extracts jsdoc typed array 1`] = ` { "description": null, "params": [ @@ -74,7 +74,7 @@ exports[`parseJsDoc @param extracts jsdoc typed array 1`] = ` } `; -exports[`parseJsDoc @param extracts jsdoc union type param 1`] = ` +exports[`parseJsDoc > @param > extracts jsdoc union type param 1`] = ` { "description": null, "params": [ @@ -107,7 +107,7 @@ exports[`parseJsDoc @param extracts jsdoc union type param 1`] = ` } `; -exports[`parseJsDoc @returns extracts description from jsdoc 1`] = ` +exports[`parseJsDoc > @returns > extracts description from jsdoc 1`] = ` { "description": null, "params": [], @@ -118,7 +118,7 @@ exports[`parseJsDoc @returns extracts description from jsdoc 1`] = ` } `; -exports[`parseJsDoc @returns extracts jsdoc mixed types 1`] = ` +exports[`parseJsDoc > @returns > extracts jsdoc mixed types 1`] = ` { "description": null, "params": [], @@ -131,7 +131,7 @@ exports[`parseJsDoc @returns extracts jsdoc mixed types 1`] = ` } `; -exports[`parseJsDoc @returns extracts jsdoc typed array 1`] = ` +exports[`parseJsDoc > @returns > extracts jsdoc typed array 1`] = ` { "description": null, "params": [ @@ -156,7 +156,7 @@ exports[`parseJsDoc @returns extracts jsdoc typed array 1`] = ` } `; -exports[`parseJsDoc @returns extracts jsdoc types 1`] = ` +exports[`parseJsDoc > @returns > extracts jsdoc types 1`] = ` { "description": null, "params": [], @@ -169,7 +169,7 @@ exports[`parseJsDoc @returns extracts jsdoc types 1`] = ` } `; -exports[`parseJsDoc @returns works with @return 1`] = ` +exports[`parseJsDoc > @returns > works with @return 1`] = ` { "description": null, "params": [], @@ -180,7 +180,7 @@ exports[`parseJsDoc @returns works with @return 1`] = ` } `; -exports[`parseJsDoc description extracts the method description in jsdoc 1`] = ` +exports[`parseJsDoc > description > extracts the method description in jsdoc 1`] = ` { "description": "Don't use this!", "params": [], diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/printValue-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/printValue-test.ts.snap index 4534a0b3225..724aeb4294d 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/printValue-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/printValue-test.ts.snap @@ -1,27 +1,27 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`printValue deindents code 1`] = ` +exports[`printValue > deindents code 1`] = ` "function () { return x; }" `; -exports[`printValue removes trailing , for TsCallSignatureDeclaration 1`] = `"(): number"`; +exports[`printValue > removes trailing , for TsCallSignatureDeclaration 1`] = `"(): number"`; -exports[`printValue removes trailing , for TsConstructSignatureDeclaration 1`] = `"new (x:number)"`; +exports[`printValue > removes trailing , for TsConstructSignatureDeclaration 1`] = `"new (x:number)"`; -exports[`printValue removes trailing , for TsIndexSignature 1`] = `"[x:string]: number"`; +exports[`printValue > removes trailing , for TsIndexSignature 1`] = `"[x:string]: number"`; -exports[`printValue removes trailing , for TsMethodSignature 1`] = `"x(): number"`; +exports[`printValue > removes trailing , for TsMethodSignature 1`] = `"x(): number"`; -exports[`printValue removes trailing , for TsPropertySignature 1`] = `"x: number"`; +exports[`printValue > removes trailing , for TsPropertySignature 1`] = `"x: number"`; -exports[`printValue removes trailing ; for TsCallSignatureDeclaration 1`] = `"(): number"`; +exports[`printValue > removes trailing ; for TsCallSignatureDeclaration 1`] = `"(): number"`; -exports[`printValue removes trailing ; for TsConstructSignatureDeclaration 1`] = `"new (x:number)"`; +exports[`printValue > removes trailing ; for TsConstructSignatureDeclaration 1`] = `"new (x:number)"`; -exports[`printValue removes trailing ; for TsIndexSignature 1`] = `"[x:string]: number"`; +exports[`printValue > removes trailing ; for TsIndexSignature 1`] = `"[x:string]: number"`; -exports[`printValue removes trailing ; for TsMethodSignature 1`] = `"x(): number"`; +exports[`printValue > removes trailing ; for TsMethodSignature 1`] = `"x(): number"`; -exports[`printValue removes trailing ; for TsPropertySignature 1`] = `"x: number"`; +exports[`printValue > removes trailing ; for TsPropertySignature 1`] = `"x: number"`; diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveFunctionDefinitionToReturnValue-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveFunctionDefinitionToReturnValue-test.ts.snap index 21262fcd4d0..c414f97b43c 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveFunctionDefinitionToReturnValue-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveFunctionDefinitionToReturnValue-test.ts.snap @@ -1,9 +1,9 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`resolveFunctionDefinitionToReturnValue can resolve easy return statement 1`] = ` +exports[`resolveFunctionDefinitionToReturnValue > can resolve easy return statement 1`] = ` Node { "extra": { - "raw": ""result"", + "raw": "\\"result\\"", "rawValue": "result", }, "type": "StringLiteral", @@ -11,10 +11,10 @@ Node { } `; -exports[`resolveFunctionDefinitionToReturnValue stops after first return 1`] = ` +exports[`resolveFunctionDefinitionToReturnValue > stops after first return 1`] = ` Node { "extra": { - "raw": ""first"", + "raw": "\\"first\\"", "rawValue": "first", }, "type": "StringLiteral", diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveGenericTypeAnnotations-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveGenericTypeAnnotations-test.ts.snap index b9a3f68acde..ab98e358c96 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveGenericTypeAnnotations-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveGenericTypeAnnotations-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`resolveGenericTypeAnnotation resolves type 1`] = ` +exports[`resolveGenericTypeAnnotation > resolves type 1`] = ` Node { "callProperties": [], "exact": false, diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveHOC-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveHOC-test.ts.snap new file mode 100644 index 00000000000..07d3ec61d42 --- /dev/null +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveHOC-test.ts.snap @@ -0,0 +1,96 @@ +// Vitest Snapshot v1 + +exports[`resolveHOC > can resolve an hocs inside imported component passed to hoc 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > can resolve an imported component passed to hoc 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > can resolve an imported component passed to nested hoc 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > resolves HOC as last element if first is array 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > resolves HOC as last element if first is literal 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > resolves HOC as last element if first is object 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > resolves HOC as last element if first is spread 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > resolves HOC with additional params 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > resolves intermediate hocs 1`] = ` +Node { + "extra": { + "raw": "42", + "rawValue": 42, + }, + "type": "NumericLiteral", + "value": 42, +} +`; + +exports[`resolveHOC > resolves nested hocs 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > resolves really nested hocs 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > resolves simple hoc 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; + +exports[`resolveHOC > resolves simple hoc w/ multiple args 1`] = ` +Node { + "name": "Component", + "type": "Identifier", +} +`; diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectKeysToArray-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectKeysToArray-test.ts.snap index 3f768884825..731dd13cbfc 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectKeysToArray-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectKeysToArray-test.ts.snap @@ -1,79 +1,79 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`resolveObjectKeysToArray can resolve imported objects passed to Object.keys 1`] = ` +exports[`resolveObjectKeysToArray > can resolve imported objects passed to Object.keys 1`] = ` [ - ""bar"", - ""foo"", - ""1"", - ""2"", - ""3"", - ""baz"", + "\\"bar\\"", + "\\"foo\\"", + "\\"1\\"", + "\\"2\\"", + "\\"3\\"", + "\\"baz\\"", ] `; -exports[`resolveObjectKeysToArray can resolve spreads from imported objects 1`] = ` +exports[`resolveObjectKeysToArray > can resolve spreads from imported objects 1`] = ` [ - ""foo"", - ""baz"", - ""bar"", + "\\"foo\\"", + "\\"baz\\"", + "\\"bar\\"", ] `; -exports[`resolveObjectKeysToArray resolves Object.keys but ignores duplicates 1`] = ` +exports[`resolveObjectKeysToArray > resolves Object.keys but ignores duplicates 1`] = ` [ - ""boo"", - ""foo"", - ""doo"", + "\\"boo\\"", + "\\"foo\\"", + "\\"doo\\"", ] `; -exports[`resolveObjectKeysToArray resolves Object.keys but ignores duplicates with getter and setter 1`] = ` +exports[`resolveObjectKeysToArray > resolves Object.keys but ignores duplicates with getter and setter 1`] = ` [ - ""x"", + "\\"x\\"", ] `; -exports[`resolveObjectKeysToArray resolves Object.keys when using getters 1`] = ` +exports[`resolveObjectKeysToArray > resolves Object.keys when using getters 1`] = ` [ - ""boo"", - ""foo"", - ""bar"", + "\\"boo\\"", + "\\"foo\\"", + "\\"bar\\"", ] `; -exports[`resolveObjectKeysToArray resolves Object.keys when using resolvable spread 1`] = ` +exports[`resolveObjectKeysToArray > resolves Object.keys when using resolvable spread 1`] = ` [ - ""boo"", - ""foo"", - ""doo"", + "\\"boo\\"", + "\\"foo\\"", + "\\"doo\\"", ] `; -exports[`resolveObjectKeysToArray resolves Object.keys when using setters 1`] = ` +exports[`resolveObjectKeysToArray > resolves Object.keys when using setters 1`] = ` [ - ""boo"", - ""foo"", - ""bar"", + "\\"boo\\"", + "\\"foo\\"", + "\\"bar\\"", ] `; -exports[`resolveObjectKeysToArray resolves Object.keys with identifiers 1`] = ` +exports[`resolveObjectKeysToArray > resolves Object.keys with identifiers 1`] = ` [ - ""bar"", - ""foo"", + "\\"bar\\"", + "\\"foo\\"", ] `; -exports[`resolveObjectKeysToArray resolves Object.keys with literals 1`] = ` +exports[`resolveObjectKeysToArray > resolves Object.keys with literals 1`] = ` [ - ""bar"", - ""5"", + "\\"bar\\"", + "\\"5\\"", ] `; -exports[`resolveObjectKeysToArray resolves Object.keys with literals as computed key 1`] = ` +exports[`resolveObjectKeysToArray > resolves Object.keys with literals as computed key 1`] = ` [ - ""bar"", - ""5"", + "\\"bar\\"", + "\\"5\\"", ] `; diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectPatternPropertyToValue-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectPatternPropertyToValue-test.ts.snap index 82f1f2ba116..224aab0171b 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectPatternPropertyToValue-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectPatternPropertyToValue-test.ts.snap @@ -1,9 +1,9 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`resolveObjectPatternPropertyToValue AssignmentExpression resolved basic case 1`] = ` +exports[`resolveObjectPatternPropertyToValue > AssignmentExpression > resolved basic case 1`] = ` Node { "extra": { - "raw": ""string"", + "raw": "\\"string\\"", "rawValue": "string", }, "type": "StringLiteral", @@ -11,10 +11,10 @@ Node { } `; -exports[`resolveObjectPatternPropertyToValue VariableDeclarator resolved basic case 1`] = ` +exports[`resolveObjectPatternPropertyToValue > VariableDeclarator > resolved basic case 1`] = ` Node { "extra": { - "raw": ""string"", + "raw": "\\"string\\"", "rawValue": "string", }, "type": "StringLiteral", diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectValuesToArray-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectValuesToArray-test.ts.snap index 4288b08e5ab..a4890f931a9 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectValuesToArray-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveObjectValuesToArray-test.ts.snap @@ -1,27 +1,27 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`resolveObjectValuesToArray can resolve imported objects passed to Object.values 1`] = ` +exports[`resolveObjectValuesToArray > can resolve imported objects passed to Object.values 1`] = ` [ - ""bar"", - ""foo"", + "\\"bar\\"", + "\\"foo\\"", "0", "5", "null", "null", "7", - ""foo"", + "\\"foo\\"", ] `; -exports[`resolveObjectValuesToArray can resolve spreads from imported objects 1`] = ` +exports[`resolveObjectValuesToArray > can resolve spreads from imported objects 1`] = ` [ - ""foo"", - ""baz"", - ""bar"", + "\\"foo\\"", + "\\"baz\\"", + "\\"bar\\"", ] `; -exports[`resolveObjectValuesToArray resolves Object.values but ignores duplicates 1`] = ` +exports[`resolveObjectValuesToArray > resolves Object.values but ignores duplicates 1`] = ` [ "1", "2", @@ -29,23 +29,23 @@ exports[`resolveObjectValuesToArray resolves Object.values but ignores duplicate ] `; -exports[`resolveObjectValuesToArray resolves Object.values but ignores duplicates with getter and setter 1`] = `[]`; +exports[`resolveObjectValuesToArray > resolves Object.values but ignores duplicates with getter and setter 1`] = `[]`; -exports[`resolveObjectValuesToArray resolves Object.values when using getters 1`] = ` +exports[`resolveObjectValuesToArray > resolves Object.values when using getters 1`] = ` [ "1", "2", ] `; -exports[`resolveObjectValuesToArray resolves Object.values when using methods 1`] = ` +exports[`resolveObjectValuesToArray > resolves Object.values when using methods 1`] = ` [ "1", "2", ] `; -exports[`resolveObjectValuesToArray resolves Object.values when using resolvable spread 1`] = ` +exports[`resolveObjectValuesToArray > resolves Object.values when using resolvable spread 1`] = ` [ "1", "2", @@ -53,35 +53,35 @@ exports[`resolveObjectValuesToArray resolves Object.values when using resolvable ] `; -exports[`resolveObjectValuesToArray resolves Object.values when using setters 1`] = ` +exports[`resolveObjectValuesToArray > resolves Object.values when using setters 1`] = ` [ "1", "2", ] `; -exports[`resolveObjectValuesToArray resolves Object.values with literals as computed key 1`] = ` +exports[`resolveObjectValuesToArray > resolves Object.values with literals as computed key 1`] = ` [ "1", "2", ] `; -exports[`resolveObjectValuesToArray resolves Object.values with numbers 1`] = ` +exports[`resolveObjectValuesToArray > resolves Object.values with numbers 1`] = ` [ "0", "5", ] `; -exports[`resolveObjectValuesToArray resolves Object.values with strings 1`] = ` +exports[`resolveObjectValuesToArray > resolves Object.values with strings 1`] = ` [ - ""bar"", - ""foo"", + "\\"bar\\"", + "\\"foo\\"", ] `; -exports[`resolveObjectValuesToArray resolves Object.values with undefined or null 1`] = ` +exports[`resolveObjectValuesToArray > resolves Object.values with undefined or null 1`] = ` [ "null", "null", diff --git a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveToValue-test.ts.snap b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveToValue-test.ts.snap index e7c16994158..42d164fb997 100644 --- a/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveToValue-test.ts.snap +++ b/packages/react-docgen/src/utils/__tests__/__snapshots__/resolveToValue-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`resolveToValue ImportDeclaration does not crash when resolving MemberExpression with non Identifiers 1`] = ` +exports[`resolveToValue > ImportDeclaration > does not crash when resolving MemberExpression with non Identifiers 1`] = ` Node { "computed": true, "object": Node { @@ -23,7 +23,7 @@ Node { } `; -exports[`resolveToValue ImportDeclaration resolves namespace import references to the import declaration 1`] = ` +exports[`resolveToValue > ImportDeclaration > resolves namespace import references to the import declaration 1`] = ` Node { "extra": { "raw": "3", @@ -34,7 +34,7 @@ Node { } `; -exports[`resolveToValue ImportDeclaration resolves namespace import references to the import declaration 2`] = ` +exports[`resolveToValue > ImportDeclaration > resolves namespace import references to the import declaration 2`] = ` Node { "extra": { "raw": "3", @@ -44,3 +44,133 @@ Node { "value": 3, } `; + +exports[`resolveToValue > MemberExpression > resolves a MemberExpression in the scope chain 1`] = ` +Node { + "extra": { + "raw": "1", + "rawValue": 1, + }, + "type": "NumericLiteral", + "value": 1, +} +`; + +exports[`resolveToValue > MemberExpression > resolves a MemberExpression to it's init value 1`] = ` +Node { + "extra": { + "raw": "1", + "rawValue": 1, + }, + "type": "NumericLiteral", + "value": 1, +} +`; + +exports[`resolveToValue > MemberExpression > resolves a nested MemberExpression in the scope chain 1`] = ` +Node { + "extra": { + "raw": "1", + "rawValue": 1, + }, + "type": "NumericLiteral", + "value": 1, +} +`; + +exports[`resolveToValue > MemberExpression > returns the last resolvable MemberExpression 1`] = ` +Node { + "computed": false, + "object": Node { + "name": "foo", + "type": "Identifier", + }, + "property": Node { + "name": "bar", + "type": "Identifier", + }, + "type": "MemberExpression", +} +`; + +exports[`resolveToValue > assignments > resolves to assigned values 1`] = ` +Node { + "extra": { + "raw": "42", + "rawValue": 42, + }, + "type": "NumericLiteral", + "value": 42, +} +`; + +exports[`resolveToValue > assignments > resolves to other assigned value if ref is in an assignment lhs 1`] = ` +Node { + "extra": { + "raw": "42", + "rawValue": 42, + }, + "type": "NumericLiteral", + "value": 42, +} +`; + +exports[`resolveToValue > assignments > resolves to other assigned value if ref is in an assignment rhs 1`] = ` +Node { + "extra": { + "raw": "42", + "rawValue": 42, + }, + "type": "NumericLiteral", + "value": 42, +} +`; + +exports[`resolveToValue > handles RestElements properly 1`] = ` +Node { + "argument": Node { + "name": "baz", + "type": "Identifier", + }, + "type": "RestElement", +} +`; + +exports[`resolveToValue > resolves object destructuring 1`] = ` +Node { + "computed": false, + "key": Node { + "name": "bar", + "type": "Identifier", + }, + "method": false, + "shorthand": false, + "type": "ObjectProperty", + "value": Node { + "name": "baz", + "type": "Identifier", + }, +} +`; + +exports[`resolveToValue > resolves simple variable declarations 1`] = ` +Node { + "extra": { + "raw": "42", + "rawValue": 42, + }, + "type": "NumericLiteral", + "value": 42, +} +`; + +exports[`resolveToValue > resolves variable declarators to their init value 1`] = ` +Node { + "extra": { + "raw": "42", + "rawValue": 42, + }, + "type": "NumericLiteral", + "value": 42, +} +`; diff --git a/packages/react-docgen/src/utils/__tests__/docblock-test.ts b/packages/react-docgen/src/utils/__tests__/docblock-test.ts index 50be859793c..0d945eec0b9 100644 --- a/packages/react-docgen/src/utils/__tests__/docblock-test.ts +++ b/packages/react-docgen/src/utils/__tests__/docblock-test.ts @@ -1,23 +1,24 @@ import { parse } from '../../../tests/utils'; -import { getDoclets, getDocblock } from '../docblock'; +import { getDoclets, getDocblock } from '../docblock.js'; +import { describe, expect, test } from 'vitest'; describe('docblock', () => { describe('getDoclets', () => { - it('extracts single line doclets', () => { + test('extracts single line doclets', () => { expect(getDoclets('@foo bar\n@bar baz')).toEqual({ foo: 'bar', bar: 'baz', }); }); - it('extracts multi line doclets', () => { + test('extracts multi line doclets', () => { expect(getDoclets('@foo bar\nbaz\n@bar baz')).toEqual({ foo: 'bar\nbaz', bar: 'baz', }); }); - it('extracts boolean doclets', () => { + test('extracts boolean doclets', () => { expect(getDoclets('@foo bar\nbaz\n@abc\n@bar baz')).toEqual({ foo: 'bar\nbaz', abc: true, @@ -36,7 +37,7 @@ describe('docblock', () => { 'foo;', ]; - it('gets the closest docblock of the given node', () => { + test('gets the closest docblock of the given node', () => { const node = parse.statement(source.join('\n')); expect(getDocblock(node)).toEqual(comment.join('\n')); @@ -51,14 +52,14 @@ describe('docblock', () => { ]; terminators.forEach(t => { - it('can handle ' + escape(t) + ' as line terminator', () => { + test('can handle ' + escape(t) + ' as line terminator', () => { const node = parse.statement(source.join(t)); expect(getDocblock(node)).toEqual(comment.join(t)); }); }); - it('supports "short" docblocks', () => { + test('supports "short" docblocks', () => { const node = parse.statement('/** bar */\nfoo;'); expect(getDocblock(node)).toEqual('bar'); diff --git a/packages/react-docgen/src/utils/__tests__/expressionTo-test.ts b/packages/react-docgen/src/utils/__tests__/expressionTo-test.ts index c31ddac8288..11635244930 100644 --- a/packages/react-docgen/src/utils/__tests__/expressionTo-test.ts +++ b/packages/react-docgen/src/utils/__tests__/expressionTo-test.ts @@ -1,9 +1,10 @@ import { parse, parseTypescript } from '../../../tests/utils'; -import { Array as expressionToArray } from '../expressionTo'; +import { Array as expressionToArray } from '../expressionTo.js'; +import { describe, expect, test } from 'vitest'; describe('expressionTo', () => { describe('MemberExpression', () => { - it('with only identifiers', () => { + test('with only identifiers', () => { expect(expressionToArray(parse.expression('foo.bar.baz'))).toEqual([ 'foo', 'bar', @@ -11,7 +12,7 @@ describe('expressionTo', () => { ]); }); - it('with one computed literal', () => { + test('with one computed literal', () => { expect(expressionToArray(parse.expression('foo["bar"].baz'))).toEqual([ 'foo', '"bar"', @@ -19,7 +20,7 @@ describe('expressionTo', () => { ]); }); - it('with one computed identifier', () => { + test('with one computed identifier', () => { expect(expressionToArray(parse.expression('foo[bar].baz'))).toEqual([ 'foo', 'bar', @@ -27,13 +28,13 @@ describe('expressionTo', () => { ]); }); - it('with one computed object', () => { + test('with one computed object', () => { expect( expressionToArray(parse.expression('foo[{ a: "true"}].baz')), ).toEqual(['foo', '{a: "true"}', 'baz']); }); - it('with one computed object with spread', () => { + test('with one computed object with spread', () => { expect(expressionToArray(parse.expression('foo[{ ...a }].baz'))).toEqual([ 'foo', '{...a}', @@ -41,13 +42,13 @@ describe('expressionTo', () => { ]); }); - it('with one computed object with method', () => { + test('with one computed object with method', () => { expect(expressionToArray(parse.expression('foo[{ a(){} }].baz'))).toEqual( ['foo', '{a: }', 'baz'], ); }); - it('with TSAsExpression', () => { + test('with TSAsExpression', () => { expect( expressionToArray(parseTypescript.expression('(baz as X).prop')), ).toEqual(['baz', 'prop']); diff --git a/packages/react-docgen/src/utils/__tests__/findFunctionReturn-test.ts b/packages/react-docgen/src/utils/__tests__/findFunctionReturn-test.ts index 9407b077e50..70a884c7056 100644 --- a/packages/react-docgen/src/utils/__tests__/findFunctionReturn-test.ts +++ b/packages/react-docgen/src/utils/__tests__/findFunctionReturn-test.ts @@ -2,7 +2,8 @@ import type { NodePath } from '@babel/traverse'; import type { StringLiteral } from '@babel/types'; import { parse, makeMockImporter, noopImporter } from '../../../tests/utils'; import type { Importer } from '../../importer'; -import findFunctionReturn from '../findFunctionReturn'; +import findFunctionReturn from '../findFunctionReturn.js'; +import { describe, expect, test } from 'vitest'; const predicate = (path: NodePath): boolean => path.isStringLiteral() && @@ -95,7 +96,7 @@ describe('findFunctionReturn', () => { Object.keys(modifiers).forEach(modifierName => { const modifierFactory = modifiers[modifierName]; - it(modifierName, () => { + test(modifierName, () => { const code = caseFactory(modifierFactory(), functionFactory); const def: NodePath = parse(code).get( `${caseSelector}.${functionSelector}`.replace(/\.$/, ''), @@ -108,7 +109,7 @@ describe('findFunctionReturn', () => { Object.keys(negativeModifiers).forEach(modifierName => { const modifierFactory = negativeModifiers[modifierName]; - it(modifierName, () => { + test(modifierName, () => { const code = caseFactory(modifierFactory(), functionFactory); const def: NodePath = parse(code).get( @@ -125,12 +126,12 @@ describe('findFunctionReturn', () => { }); describe('resolving return values', () => { - function test( + function testReturnValues( desc: string, src: string, importer: Importer = noopImporter, ) { - it(desc, () => { + test(desc, () => { const def = parse(src, importer).get('body')[0]; expectValue(findFunctionReturn(def, predicate)); @@ -141,7 +142,7 @@ describe('findFunctionReturn', () => { bar: stmtLast => stmtLast(`export default "value";`).get('declaration'), }); - it('handles recursive function calls', () => { + test('handles recursive function calls', () => { const def = parse.statement(` function Foo (props) { return props && Foo(props); @@ -151,7 +152,7 @@ describe('findFunctionReturn', () => { expect(findFunctionReturn(def, predicate)).toBeUndefined(); }); - test( + testReturnValues( 'does not see ifs as separate block', ` function Foo (props) { @@ -162,7 +163,7 @@ describe('findFunctionReturn', () => { `, ); - test( + testReturnValues( 'handles simple resolves', ` function Foo (props) { @@ -175,7 +176,7 @@ describe('findFunctionReturn', () => { `, ); - test( + testReturnValues( 'handles reference resolves', ` function Foo (props) { @@ -190,7 +191,7 @@ describe('findFunctionReturn', () => { `, ); - test( + testReturnValues( 'handles shallow member call expression resolves', ` function Foo (props) { @@ -205,7 +206,7 @@ describe('findFunctionReturn', () => { `, ); - test( + testReturnValues( 'handles deep member call expression resolves', ` function Foo (props) { @@ -222,7 +223,7 @@ describe('findFunctionReturn', () => { `, ); - test( + testReturnValues( 'handles external reference member call expression resolves', ` function Foo (props) { @@ -238,7 +239,7 @@ describe('findFunctionReturn', () => { `, ); - test( + testReturnValues( 'handles all sorts of JavaScript things', ` function Foo (props) { @@ -252,7 +253,7 @@ describe('findFunctionReturn', () => { `, ); - test( + testReturnValues( 'resolves imported values as return', ` function Foo (props) { diff --git a/packages/react-docgen/src/utils/__tests__/flowUtilityTypes-test.ts b/packages/react-docgen/src/utils/__tests__/flowUtilityTypes-test.ts index 5c4f1937911..19d6aa85118 100644 --- a/packages/react-docgen/src/utils/__tests__/flowUtilityTypes-test.ts +++ b/packages/react-docgen/src/utils/__tests__/flowUtilityTypes-test.ts @@ -1,11 +1,15 @@ -import { unwrapUtilityType, isSupportedUtilityType } from '../flowUtilityTypes'; +import { + unwrapUtilityType, + isSupportedUtilityType, +} from '../flowUtilityTypes.js'; import { parse } from '../../../tests/utils'; import type { NodePath } from '@babel/traverse'; import type { GenericTypeAnnotation, TypeAlias } from '@babel/types'; +import { describe, expect, test } from 'vitest'; describe('flowTypeUtilities', () => { describe('unwrapUtilityType', () => { - it('correctly unwraps', () => { + test('correctly unwraps', () => { const def = parse.statement(` type A = $ReadOnly<{ foo: string }> `); @@ -17,7 +21,7 @@ describe('flowTypeUtilities', () => { ); }); - it('correctly unwraps double', () => { + test('correctly unwraps double', () => { const def = parse.statement(` type A = $ReadOnly<$ReadOnly<{ foo: string }>> `); @@ -33,7 +37,7 @@ describe('flowTypeUtilities', () => { ); }); - it('correctly unwraps triple', () => { + test('correctly unwraps triple', () => { const def = parse.statement(` type A = $ReadOnly<$ReadOnly<$ReadOnly<{ foo: string }>>> `); @@ -55,7 +59,7 @@ describe('flowTypeUtilities', () => { }); describe('isSupportedUtilityType', () => { - it('correctly returns true for $Exact', () => { + test('correctly returns true for $Exact', () => { const def = parse.statement(` type A = $Exact<{ foo: string }> `); @@ -63,7 +67,7 @@ describe('flowTypeUtilities', () => { expect(isSupportedUtilityType(def.get('right'))).toBe(true); }); - it('correctly returns true for $ReadOnly', () => { + test('correctly returns true for $ReadOnly', () => { const def = parse.statement(` type A = $ReadOnly<{ foo: string }> `); @@ -71,7 +75,7 @@ describe('flowTypeUtilities', () => { expect(isSupportedUtilityType(def.get('right'))).toBe(true); }); - it('correctly returns false for invalid type', () => { + test('correctly returns false for invalid type', () => { const def = parse.statement(` type A = $Homer<{ foo: string }> `); @@ -79,7 +83,7 @@ describe('flowTypeUtilities', () => { expect(isSupportedUtilityType(def.get('right'))).toBe(false); }); - it('correctly returns false for QualifiedTypeIdentifier', () => { + test('correctly returns false for QualifiedTypeIdentifier', () => { const def = parse.statement(` type A = $Homer.Marge<{ foo: string }> `); diff --git a/packages/react-docgen/src/utils/__tests__/getClassMemberValuePath-test.ts b/packages/react-docgen/src/utils/__tests__/getClassMemberValuePath-test.ts index 31f4aa86da3..4883bd91eab 100644 --- a/packages/react-docgen/src/utils/__tests__/getClassMemberValuePath-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getClassMemberValuePath-test.ts @@ -1,11 +1,12 @@ -import getClassMemberValuePath from '../getClassMemberValuePath'; +import getClassMemberValuePath from '../getClassMemberValuePath.js'; import { parse } from '../../../tests/utils'; import type { ClassDeclaration, ClassExpression } from '@babel/types'; +import { describe, expect, test } from 'vitest'; describe('getClassMemberValuePath', () => { describe('ClassDeclaration', () => { describe('MethodDefinitions', () => { - it('finds "normal" method definitions', () => { + test('finds "normal" method definitions', () => { const def = parse.statement(` class Foo { render() {} @@ -15,7 +16,7 @@ describe('getClassMemberValuePath', () => { expect(getClassMemberValuePath(def, 'render')).toMatchSnapshot(); }); - it('finds computed method definitions with literal keys', () => { + test('finds computed method definitions with literal keys', () => { const def = parse.statement(` class Foo { ['render']() {} @@ -25,7 +26,7 @@ describe('getClassMemberValuePath', () => { expect(getClassMemberValuePath(def, 'render')).toMatchSnapshot(); }); - it('ignores computed method definitions with expression', () => { + test('ignores computed method definitions with expression', () => { const def = parse.statement(` class Foo { [render]() {} @@ -37,7 +38,7 @@ describe('getClassMemberValuePath', () => { }); describe('Getters and Setters', () => { - it('finds getters', () => { + test('finds getters', () => { const def = parse.statement(` class Foo { get foo() {} @@ -47,7 +48,7 @@ describe('getClassMemberValuePath', () => { expect(getClassMemberValuePath(def, 'foo')).toMatchSnapshot(); }); - it('ignores setters', () => { + test('ignores setters', () => { const def = parse.statement(` class Foo { set foo(val) {} @@ -59,7 +60,7 @@ describe('getClassMemberValuePath', () => { }); describe('ClassProperty', () => { - it('finds "normal" class properties', () => { + test('finds "normal" class properties', () => { const def = parse.statement(` class Foo { foo = 42; @@ -73,7 +74,7 @@ describe('getClassMemberValuePath', () => { }); describe('private', () => { - it('ignores private class properties', () => { + test('ignores private class properties', () => { const def = parse.statement(` class Foo { #foo = 42; @@ -83,7 +84,7 @@ describe('getClassMemberValuePath', () => { expect(getClassMemberValuePath(def, 'foo')).toBeNull(); }); - it('ignores private class methods', () => { + test('ignores private class methods', () => { const def = parse.statement(` class Foo { #foo() {} @@ -93,7 +94,7 @@ describe('getClassMemberValuePath', () => { expect(getClassMemberValuePath(def, 'foo')).toBeNull(); }); - it('finds "normal" class properties with private present', () => { + test('finds "normal" class properties with private present', () => { const def = parse.statement(` class Foo { #private = 54; @@ -109,7 +110,7 @@ describe('getClassMemberValuePath', () => { }); describe('ClassExpression', () => { - it('finds "normal" method definitions', () => { + test('finds "normal" method definitions', () => { const def = parse.expression(` class Foo { render() {} diff --git a/packages/react-docgen/src/utils/__tests__/getFlowType-test.ts b/packages/react-docgen/src/utils/__tests__/getFlowType-test.ts index ab8ee70e499..8c60e737fd8 100644 --- a/packages/react-docgen/src/utils/__tests__/getFlowType-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getFlowType-test.ts @@ -1,4 +1,4 @@ -import getFlowType from '../getFlowType'; +import getFlowType from '../getFlowType.js'; import { parse, makeMockImporter } from '../../../tests/utils'; import type { ExportNamedDeclaration, @@ -10,6 +10,7 @@ import type { VariableDeclaration, } from '@babel/types'; import type { NodePath } from '@babel/traverse'; +import { describe, expect, test } from 'vitest'; describe('getFlowType', () => { const mockImporter = makeMockImporter({ @@ -69,7 +70,7 @@ describe('getFlowType', () => { `).get('declaration') as NodePath, }); - it('detects simple types', () => { + test('detects simple types', () => { const simplePropTypes = [ 'string', 'number', @@ -96,7 +97,7 @@ describe('getFlowType', () => { }); }); - it('detects literal types', () => { + test('detects literal types', () => { const literalTypes = ['"foo"', 1234, true]; literalTypes.forEach(value => { @@ -112,7 +113,7 @@ describe('getFlowType', () => { }); }); - it('detects external type', () => { + test('detects external type', () => { const typePath = parse .expression('x: xyz') .get('typeAnnotation') @@ -121,7 +122,7 @@ describe('getFlowType', () => { expect(getFlowType(typePath)).toEqual({ name: 'xyz' }); }); - it('resolves an imported type', () => { + test('resolves an imported type', () => { const typePath = ( parse .statement( @@ -141,7 +142,7 @@ describe('getFlowType', () => { }); }); - it('detects external nullable type', () => { + test('detects external nullable type', () => { const typePath = parse .expression('x: ?xyz') .get('typeAnnotation') @@ -153,7 +154,7 @@ describe('getFlowType', () => { }); }); - it('resolves an imported nullable type', () => { + test('resolves an imported nullable type', () => { const typePath = ( parse .statement( @@ -174,7 +175,7 @@ describe('getFlowType', () => { }); }); - it('detects array type shorthand optional', () => { + test('detects array type shorthand optional', () => { const typePath = parse .expression('x: ?number[]') .get('typeAnnotation') @@ -188,7 +189,7 @@ describe('getFlowType', () => { }); }); - it('detects array type shorthand optional type', () => { + test('detects array type shorthand optional type', () => { const typePath = parse .expression('x: (?number)[]') .get('typeAnnotation') @@ -201,7 +202,7 @@ describe('getFlowType', () => { }); }); - it('detects array type shorthand', () => { + test('detects array type shorthand', () => { const typePath = parse .expression('x: number[]') .get('typeAnnotation') @@ -214,7 +215,7 @@ describe('getFlowType', () => { }); }); - it('detects array type', () => { + test('detects array type', () => { const typePath = parse .expression('x: Array') .get('typeAnnotation') @@ -227,7 +228,7 @@ describe('getFlowType', () => { }); }); - it('resolves imported types used for arrays', () => { + test('resolves imported types used for arrays', () => { let typePath = ( parse .statement( @@ -307,7 +308,7 @@ describe('getFlowType', () => { }); }); - it('detects array type with multiple types', () => { + test('detects array type with multiple types', () => { const typePath = parse .expression('x: Array') .get('typeAnnotation') @@ -320,7 +321,7 @@ describe('getFlowType', () => { }); }); - it('resolves array type with multiple imported types', () => { + test('resolves array type with multiple imported types', () => { const typePath = ( parse .statement( @@ -343,7 +344,7 @@ describe('getFlowType', () => { }); }); - it('detects class type', () => { + test('detects class type', () => { const typePath = parse .expression('x: Class') .get('typeAnnotation') @@ -356,7 +357,7 @@ describe('getFlowType', () => { }); }); - it('resolves imported subtype for class type', () => { + test('resolves imported subtype for class type', () => { const typePath = ( parse .statement( @@ -378,7 +379,7 @@ describe('getFlowType', () => { }); }); - it('detects function type with subtype', () => { + test('detects function type with subtype', () => { const typePath = parse .expression('x: Function') .get('typeAnnotation') @@ -391,7 +392,7 @@ describe('getFlowType', () => { }); }); - it('resolves imported subtype for function type', () => { + test('resolves imported subtype for function type', () => { const typePath = ( parse .statement( @@ -413,7 +414,7 @@ describe('getFlowType', () => { }); }); - it('detects object types', () => { + test('detects object types', () => { const typePath = parse .expression('x: { a: string, b?: xyz }') .get('typeAnnotation') @@ -432,7 +433,7 @@ describe('getFlowType', () => { }); }); - it('detects object types with maybe type', () => { + test('detects object types with maybe type', () => { const typePath = parse .expression('x: { a: string, b: ?xyz }') .get('typeAnnotation') @@ -451,7 +452,7 @@ describe('getFlowType', () => { }); }); - it('resolves imported types used for objects', () => { + test('resolves imported types used for objects', () => { const typePath = ( parse .statement( @@ -496,7 +497,7 @@ describe('getFlowType', () => { }); }); - it('detects union type', () => { + test('detects union type', () => { const typePath = parse .expression('x: string | xyz | "foo" | void') .get('typeAnnotation') @@ -514,7 +515,7 @@ describe('getFlowType', () => { }); }); - it('resolves imported types within union type', () => { + test('resolves imported types within union type', () => { const typePath = ( parse .statement( @@ -548,7 +549,7 @@ describe('getFlowType', () => { }); }); - it('detects intersection type', () => { + test('detects intersection type', () => { const typePath = parse .expression('x: string & xyz & "foo" & void') .get('typeAnnotation') @@ -566,7 +567,7 @@ describe('getFlowType', () => { }); }); - it('resolves imported types within intersection type', () => { + test('resolves imported types within intersection type', () => { const typePath = ( parse .statement( @@ -600,7 +601,7 @@ describe('getFlowType', () => { }); }); - it('detects function signature type', () => { + test('detects function signature type', () => { const typePath = parse .expression( 'x: (p1: number, p2: ?string, ...rest: Array) => boolean', @@ -631,7 +632,7 @@ describe('getFlowType', () => { }); }); - it('detects function signature types without parameter names', () => { + test('detects function signature types without parameter names', () => { const typePath = parse .expression('x: (number, ?string) => boolean') .get('typeAnnotation') @@ -651,7 +652,7 @@ describe('getFlowType', () => { }); }); - it('detects function signature type with single parmeter without name', () => { + test('detects function signature type with single parmeter without name', () => { const typePath = parse .expression('x: string => boolean') .get('typeAnnotation') @@ -668,7 +669,7 @@ describe('getFlowType', () => { }); }); - it('detects callable signature type', () => { + test('detects callable signature type', () => { const typePath = parse .expression( 'x: { (str: string): string, token: string }', @@ -697,7 +698,7 @@ describe('getFlowType', () => { }); }); - it('resolves function signature types with imported types', () => { + test('resolves function signature types with imported types', () => { let typePath = ( parse .statement( @@ -827,7 +828,7 @@ describe('getFlowType', () => { }); }); - it('detects map signature', () => { + test('detects map signature', () => { const typePath = parse .expression( 'x: { [key: string]: number, [key: "xl"]: string, token: "a" | "b" }', @@ -866,7 +867,7 @@ describe('getFlowType', () => { }); }); - it('resolves imported types in map signature', () => { + test('resolves imported types in map signature', () => { const typePath = ( parse .statement( @@ -915,7 +916,7 @@ describe('getFlowType', () => { }); }); - it('detects tuple signature', () => { + test('detects tuple signature', () => { const typePath = parse .expression('x: [string, number]') .get('typeAnnotation') @@ -928,7 +929,7 @@ describe('getFlowType', () => { }); }); - it('detects tuple in union signature', () => { + test('detects tuple in union signature', () => { const typePath = parse .expression('x: [string, number] | [number, string]') .get('typeAnnotation') @@ -952,7 +953,7 @@ describe('getFlowType', () => { }); }); - it('resolves imported types used in tuple signature', () => { + test('resolves imported types used in tuple signature', () => { let typePath = ( parse .statement( @@ -1008,7 +1009,7 @@ describe('getFlowType', () => { }); }); - it('resolves types in scope', () => { + test('resolves types in scope', () => { const typePath = ( parse .statement( @@ -1029,7 +1030,7 @@ describe('getFlowType', () => { }); }); - it('handles typeof types', () => { + test('handles typeof types', () => { const typePath = ( parse .statement( @@ -1058,7 +1059,7 @@ describe('getFlowType', () => { }); }); - it('resolves typeof of imported types', () => { + test('resolves typeof of imported types', () => { const typePath = ( parse .statement( @@ -1090,7 +1091,7 @@ describe('getFlowType', () => { }); }); - it('handles qualified type identifiers', () => { + test('handles qualified type identifiers', () => { const typePath = ( parse .statement( @@ -1111,7 +1112,7 @@ describe('getFlowType', () => { }); }); - it('handles qualified type identifiers with params', () => { + test('handles qualified type identifiers with params', () => { const typePath = ( parse .statement( @@ -1138,7 +1139,7 @@ describe('getFlowType', () => { }); }); - it('handles generic types', () => { + test('handles generic types', () => { const typePath = ( parse .statement( @@ -1181,7 +1182,7 @@ describe('getFlowType', () => { }); }); - it('resolves imported types that need subtypes', () => { + test('resolves imported types that need subtypes', () => { const typePath = ( parse .statement( @@ -1225,7 +1226,7 @@ describe('getFlowType', () => { }); describe('React types', () => { - function test(type, expected) { + function testReactType(type, expected) { const typePath = ( parse .statement( @@ -1277,11 +1278,11 @@ describe('getFlowType', () => { }; Object.keys(types).forEach(type => { - it(type, () => test(type, types[type])); + test(type, () => testReactType(type, types[type])); }); }); - it('resolves $Keys to union', () => { + test('resolves $Keys to union', () => { const typePath = ( parse .statement( @@ -1309,7 +1310,7 @@ describe('getFlowType', () => { }); }); - it('resolves $Keys without typeof to union', () => { + test('resolves $Keys without typeof to union', () => { const typePath = ( parse .statement( @@ -1337,7 +1338,7 @@ describe('getFlowType', () => { }); }); - it('resolves $Keys with an ObjectTypeAnnotation typeParameter to union', () => { + test('resolves $Keys with an ObjectTypeAnnotation typeParameter to union', () => { const typePath = ( parse .statement( @@ -1361,7 +1362,7 @@ describe('getFlowType', () => { }); }); - it('resolves $Keys with an ObjectTypeAnnotation typeParameter to union with an ObjectTypeSpreadProperty', () => { + test('resolves $Keys with an ObjectTypeAnnotation typeParameter to union with an ObjectTypeSpreadProperty', () => { const typePath = ( parse .statement( @@ -1387,7 +1388,7 @@ describe('getFlowType', () => { }); }); - it('resolves $Keys to imported types', () => { + test('resolves $Keys to imported types', () => { let typePath = ( parse .statement( @@ -1462,7 +1463,7 @@ describe('getFlowType', () => { }); }); - it('handles multiple references to one type', () => { + test('handles multiple references to one type', () => { const typePath = ( parse .statement( @@ -1508,7 +1509,7 @@ describe('getFlowType', () => { }); }); - it('handles self-referencing type cycles', () => { + test('handles self-referencing type cycles', () => { const typePath = ( parse .statement( @@ -1535,7 +1536,7 @@ describe('getFlowType', () => { }); }); - it('handles long type cycles', () => { + test('handles long type cycles', () => { const typePath = ( parse .statement( @@ -1607,7 +1608,7 @@ describe('getFlowType', () => { }); }); - it('handles ObjectTypeSpreadProperty', () => { + test('handles ObjectTypeSpreadProperty', () => { const typePath = ( parse .statement( @@ -1625,7 +1626,7 @@ describe('getFlowType', () => { expect(getFlowType(typePath)).toMatchSnapshot(); }); - it('handles ObjectTypeSpreadProperty from imported types', () => { + test('handles ObjectTypeSpreadProperty from imported types', () => { const typePath = ( parse .statement( @@ -1644,7 +1645,7 @@ describe('getFlowType', () => { expect(getFlowType(typePath)).toMatchSnapshot(); }); - it('handles unresolved ObjectTypeSpreadProperty', () => { + test('handles unresolved ObjectTypeSpreadProperty', () => { const typePath = ( parse .statement( @@ -1660,7 +1661,7 @@ describe('getFlowType', () => { expect(getFlowType(typePath)).toMatchSnapshot(); }); - it('handles nested ObjectTypeSpreadProperty', () => { + test('handles nested ObjectTypeSpreadProperty', () => { const typePath = ( parse .statement( diff --git a/packages/react-docgen/src/utils/__tests__/getMemberExpressionRoot-test.ts b/packages/react-docgen/src/utils/__tests__/getMemberExpressionRoot-test.ts index 08409240752..07dd2ebf932 100644 --- a/packages/react-docgen/src/utils/__tests__/getMemberExpressionRoot-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getMemberExpressionRoot-test.ts @@ -1,25 +1,26 @@ import type { MemberExpression } from '@babel/types'; import { parse } from '../../../tests/utils'; -import getMemberExpressionRoot from '../getMemberExpressionRoot'; +import getMemberExpressionRoot from '../getMemberExpressionRoot.js'; +import { describe, expect, test } from 'vitest'; describe('getMemberExpressionRoot', () => { - it('returns the root of a member expression', () => { + test('returns the root of a member expression', () => { const root = getMemberExpressionRoot(parse.expression('foo.bar.baz')); - expect(root).toEqualASTNode(parse.expression('foo')); + expect(root).toMatchSnapshot(); }); - it('returns the same path if identifier', () => { + test('returns the same path if identifier', () => { const id = parse.expression('foo'); const root = getMemberExpressionRoot(id); - expect(root).toEqualASTNode(id); + expect(root).toMatchSnapshot(); }); - it('returns the same path if literal', () => { + test('returns the same path if literal', () => { const literal = parse.expression('1'); const root = getMemberExpressionRoot(literal); - expect(root).toEqualASTNode(literal); + expect(root).toMatchSnapshot(); }); }); diff --git a/packages/react-docgen/src/utils/__tests__/getMemberExpressionValuePath-test.ts b/packages/react-docgen/src/utils/__tests__/getMemberExpressionValuePath-test.ts index 30dc25ab650..26025709317 100644 --- a/packages/react-docgen/src/utils/__tests__/getMemberExpressionValuePath-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getMemberExpressionValuePath-test.ts @@ -1,9 +1,10 @@ import { parse } from '../../../tests/utils'; -import getMemberExpressionValuePath from '../getMemberExpressionValuePath'; +import getMemberExpressionValuePath from '../getMemberExpressionValuePath.js'; +import { describe, expect, test } from 'vitest'; describe('getMemberExpressionValuePath', () => { describe('MethodExpression', () => { - it('finds "normal" property definitions', () => { + test('finds "normal" property definitions', () => { const def = parse.statement(` var Foo = () => {}; Foo.propTypes = {}; @@ -14,7 +15,7 @@ describe('getMemberExpressionValuePath', () => { ); }); - it('takes the correct property definitions', () => { + test('takes the correct property definitions', () => { const def = parse.statement(` var Foo = () => {}; Foo.propTypes = {}; @@ -26,7 +27,7 @@ describe('getMemberExpressionValuePath', () => { ); }); - it('finds computed property definitions with literal keys', () => { + test('finds computed property definitions with literal keys', () => { const def = parse.statement(` function Foo () {} Foo['render'] = () => {}; @@ -37,7 +38,7 @@ describe('getMemberExpressionValuePath', () => { ); }); - it('ignores computed property definitions with expression', () => { + test('ignores computed property definitions with expression', () => { const def = parse.statement(` var Foo = function Bar() {}; Foo[imComputed] = () => {}; @@ -47,7 +48,7 @@ describe('getMemberExpressionValuePath', () => { }); }); describe('TaggedTemplateLiteral', () => { - it('finds "normal" property definitions', () => { + test('finds "normal" property definitions', () => { const def = parse.statement(` var Foo = foo\`bar\` Foo.propTypes = {}; @@ -59,7 +60,7 @@ describe('getMemberExpressionValuePath', () => { }); }); describe('CallExpression', () => { - it('finds "normal" property definitions', () => { + test('finds "normal" property definitions', () => { const def = parse.statement(` const Foo = system({is: "button"}, "space"); Foo.propTypes = {}; diff --git a/packages/react-docgen/src/utils/__tests__/getMemberValuePath-test.ts b/packages/react-docgen/src/utils/__tests__/getMemberValuePath-test.ts index 39a1e410775..6c97736bb83 100644 --- a/packages/react-docgen/src/utils/__tests__/getMemberValuePath-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getMemberValuePath-test.ts @@ -1,8 +1,8 @@ import { parse } from '../../../tests/utils'; -import getPropertyValuePath from '../getPropertyValuePath'; -import getClassMemberValuePath from '../getClassMemberValuePath'; -import getMemberValuePath from '../getMemberValuePath'; -import getMemberExpressionValuePath from '../getMemberExpressionValuePath'; +import getPropertyValuePath from '../getPropertyValuePath.js'; +import getClassMemberValuePath from '../getClassMemberValuePath.js'; +import getMemberValuePath from '../getMemberValuePath.js'; +import getMemberExpressionValuePath from '../getMemberExpressionValuePath.js'; import type { CallExpression, ClassDeclaration, @@ -10,41 +10,43 @@ import type { ObjectExpression, TaggedTemplateExpression, } from '@babel/types'; +import { describe, expect, test, vi } from 'vitest'; -jest.mock('../getPropertyValuePath'); -jest.mock('../getClassMemberValuePath'); -jest.mock('../getMemberExpressionValuePath'); +vi.mock('../getPropertyValuePath.js'); +vi.mock('../getClassMemberValuePath.js'); +vi.mock('../getMemberExpressionValuePath.js'); -describe('getMemberValuePath', () => { - it('handles ObjectExpressions', () => { +// https://github.com/vitest-dev/vitest/issues/2381 +describe.skip('getMemberValuePath', () => { + test('handles ObjectExpressions', () => { const path = parse.expression('{}'); getMemberValuePath(path, 'foo'); expect(getPropertyValuePath).toBeCalledWith(path, 'foo'); }); - it('handles ClassDeclarations', () => { + test('handles ClassDeclarations', () => { const path = parse.statement('class Foo {}'); getMemberValuePath(path, 'foo'); expect(getClassMemberValuePath).toBeCalledWith(path, 'foo'); }); - it('handles TaggedTemplateLiterals', () => { + test('handles TaggedTemplateLiterals', () => { const path = parse.expression('foo``'); getMemberValuePath(path, 'foo'); expect(getMemberExpressionValuePath).toBeCalledWith(path, 'foo'); }); - it('handles ClassExpressions', () => { + test('handles ClassExpressions', () => { const path = parse.expression('class {}'); getMemberValuePath(path, 'foo'); expect(getClassMemberValuePath).toBeCalledWith(path, 'foo'); }); - it('handles CallExpressions', () => { + test('handles CallExpressions', () => { const path = parse.expression( 'system({is: "button"}, "space")', ); @@ -54,7 +56,7 @@ describe('getMemberValuePath', () => { }); describe('tries defaultProps synonyms', () => { - it('with object', () => { + test('with object', () => { const path = parse.expression('{}'); getMemberValuePath(path, 'defaultProps'); @@ -62,7 +64,7 @@ describe('getMemberValuePath', () => { expect(getPropertyValuePath).toBeCalledWith(path, 'getDefaultProps'); }); - it('with class', () => { + test('with class', () => { const path = parse.statement('class Foo {}'); getMemberValuePath(path, 'defaultProps'); @@ -71,12 +73,12 @@ describe('getMemberValuePath', () => { }); }); - it('returns the result of getPropertyValuePath and getClassMemberValuePath', () => { + test('returns the result of getPropertyValuePath and getClassMemberValuePath', () => { const mockPath = parse.expression('42'); const mockPath2 = parse.expression('21'); - jest.mocked(getPropertyValuePath).mockReturnValue(mockPath); - jest.mocked(getClassMemberValuePath).mockReturnValue(mockPath2); + vi.mocked(getPropertyValuePath).mockReturnValue(mockPath); + vi.mocked(getClassMemberValuePath).mockReturnValue(mockPath2); let path = parse.expression('{}'); expect(getMemberValuePath(path, 'defaultProps')).toBe(mockPath); diff --git a/packages/react-docgen/src/utils/__tests__/getMembers-test.ts b/packages/react-docgen/src/utils/__tests__/getMembers-test.ts index 9ba6ad8e809..b0929dadfb4 100644 --- a/packages/react-docgen/src/utils/__tests__/getMembers-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getMembers-test.ts @@ -1,26 +1,27 @@ import { parse } from '../../../tests/utils'; -import getMembers from '../getMembers'; +import getMembers from '../getMembers.js'; +import { describe, expect, test } from 'vitest'; describe('getMembers', () => { - it('finds all "members" "inside" a MemberExpression', () => { + test('finds all "members" "inside" a MemberExpression', () => { const members = getMembers(parse.expression('foo.bar(123)(456)[baz][42]')); expect(members).toMatchSnapshot(); }); - it('includes the root if option set to true', () => { + test('includes the root if option set to true', () => { const members = getMembers(parse.expression('foo.bar(123)[baz]'), true); expect(members).toMatchSnapshot(); }); - it('does work with custom expressions in chain', () => { + test('does work with custom expressions in chain', () => { const members = getMembers(parse.expression('foo.bar(123)["" + ""]')); expect(members).toMatchSnapshot(); }); - it('does work with custom expressions in arguments', () => { + test('does work with custom expressions in arguments', () => { const members = getMembers(parse.expression('foo.bar(123 + 123)["baz"]')); expect(members).toMatchSnapshot(); diff --git a/packages/react-docgen/src/utils/__tests__/getMethodDocumentation-test.ts b/packages/react-docgen/src/utils/__tests__/getMethodDocumentation-test.ts index a6a0b2599ec..beac85689dc 100644 --- a/packages/react-docgen/src/utils/__tests__/getMethodDocumentation-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getMethodDocumentation-test.ts @@ -8,7 +8,8 @@ import type { ObjectMethod, } from '@babel/types'; import { parse, makeMockImporter, parseTypescript } from '../../../tests/utils'; -import getMethodDocumentation from '../getMethodDocumentation'; +import getMethodDocumentation from '../getMethodDocumentation.js'; +import { describe, expect, test } from 'vitest'; describe('getMethodDocumentation', () => { const mockImporter = makeMockImporter({ @@ -29,7 +30,7 @@ describe('getMethodDocumentation', () => { }); describe('name', () => { - it('extracts the method name', () => { + test('extracts the method name', () => { const def = parse.statement(` class Foo { hello() {} @@ -46,7 +47,7 @@ describe('getMethodDocumentation', () => { }); }); - it('handles function assignment', () => { + test('handles function assignment', () => { const def = parse.statement(` class Foo { hello = () => {} @@ -63,7 +64,7 @@ describe('getMethodDocumentation', () => { }); }); - it('handles computed method name', () => { + test('handles computed method name', () => { const def = parse.statement(` class Foo { [foo]() {} @@ -74,7 +75,7 @@ describe('getMethodDocumentation', () => { expect(getMethodDocumentation(method)).toMatchSnapshot(); }); - it('ignores complex computed method name', () => { + test('ignores complex computed method name', () => { const def = parse.statement(` class Foo { [() => {}]() {} @@ -85,7 +86,7 @@ describe('getMethodDocumentation', () => { expect(getMethodDocumentation(method)).toMatchSnapshot(); }); - it('resolves assignment of imported function', () => { + test('resolves assignment of imported function', () => { const def = parse.statement( ` class Foo { @@ -108,7 +109,7 @@ describe('getMethodDocumentation', () => { }); describe('docblock', () => { - it('extracts the method docblock', () => { + test('extracts the method docblock', () => { const def = parse.statement(` class Foo { /** @@ -128,7 +129,7 @@ describe('getMethodDocumentation', () => { }); }); - it('extracts docblock on function assignment', () => { + test('extracts docblock on function assignment', () => { const def = parse.statement(` class Foo { /** @@ -150,7 +151,7 @@ describe('getMethodDocumentation', () => { }); describe('parameters', () => { - it('extracts flow type info', () => { + test('extracts flow type info', () => { const def = parse.statement(` class Foo { foo(bar: number) {} @@ -161,7 +162,7 @@ describe('getMethodDocumentation', () => { expect(getMethodDocumentation(method)).toMatchSnapshot(); }); - it('extracts flow type info', () => { + test('extracts flow type info', () => { const def = parseTypescript.statement(` class Foo { foo(bar: number) {} @@ -172,7 +173,7 @@ describe('getMethodDocumentation', () => { expect(getMethodDocumentation(method)).toMatchSnapshot(); }); - it('does not add type parameters to alias', () => { + test('does not add type parameters to alias', () => { const def = parseTypescript.statement(` class Foo { foo(bar: Foo) {} @@ -183,7 +184,7 @@ describe('getMethodDocumentation', () => { expect(getMethodDocumentation(method)).toMatchSnapshot(); }); - it('extracts flow type info on function assignment', () => { + test('extracts flow type info on function assignment', () => { const def = parse.statement(` class Foo { foo = (bar: number) => {} @@ -194,7 +195,7 @@ describe('getMethodDocumentation', () => { expect(getMethodDocumentation(method)).toMatchSnapshot(); }); - it('resolves flow type info on imported functions', () => { + test('resolves flow type info on imported functions', () => { const def = parse.statement( ` class Foo { @@ -220,7 +221,7 @@ describe('getMethodDocumentation', () => { }; } - it('detects no modifiers', () => { + test('detects no modifiers', () => { const def = parse.statement(` class Foo { foo() {} @@ -231,7 +232,7 @@ describe('getMethodDocumentation', () => { expect(getMethodDocumentation(method)).toEqual(methodModifiersDoc([])); }); - it('detects static functions', () => { + test('detects static functions', () => { const def = parse.statement(` class Foo { static foo() {} @@ -244,7 +245,7 @@ describe('getMethodDocumentation', () => { ); }); - it('detects manually set static functions', () => { + test('detects manually set static functions', () => { const def = parse.expression(`{ foo() {} }`); const method = def.get('properties')[0] as NodePath; @@ -253,7 +254,7 @@ describe('getMethodDocumentation', () => { ); }); - it('detects generators', () => { + test('detects generators', () => { const def = parse.statement(` class Foo { *foo () {} @@ -266,7 +267,7 @@ describe('getMethodDocumentation', () => { ); }); - it('detects async functions', () => { + test('detects async functions', () => { const def = parse.statement(` class Foo { async foo () {} @@ -279,7 +280,7 @@ describe('getMethodDocumentation', () => { ); }); - it('detects static async functions', () => { + test('detects static async functions', () => { const def = parse.statement(` class Foo { static async foo () {} @@ -304,7 +305,7 @@ describe('getMethodDocumentation', () => { }; } - it('returns null if return is not documented', () => { + test('returns null if return is not documented', () => { const def = parse.statement(` class Foo { foo () {} @@ -315,7 +316,7 @@ describe('getMethodDocumentation', () => { expect(getMethodDocumentation(method)).toEqual(methodReturnDoc(null)); }); - it('extracts flow types', () => { + test('extracts flow types', () => { const def = parse.statement(` class Foo { foo (): number {} @@ -330,7 +331,7 @@ describe('getMethodDocumentation', () => { ); }); - it('extracts flow types on function assignment', () => { + test('extracts flow types on function assignment', () => { const def = parse.statement(` class Foo { foo = (): number => {} @@ -347,7 +348,7 @@ describe('getMethodDocumentation', () => { ); }); - it('resolves flow types on imported functions', () => { + test('resolves flow types on imported functions', () => { const def = parse.statement( ` class Foo { @@ -370,7 +371,7 @@ describe('getMethodDocumentation', () => { }); describe('private', () => { - it('ignores private typescript methods', () => { + test('ignores private typescript methods', () => { const def = parseTypescript.statement( ` class Foo { @@ -383,7 +384,7 @@ describe('getMethodDocumentation', () => { expect(getMethodDocumentation(method)).toMatchSnapshot(); }); - it('ignores private methods', () => { + test('ignores private methods', () => { const def = parse.statement( `class Foo { #foo() {} diff --git a/packages/react-docgen/src/utils/__tests__/getNameOrValue-test.ts b/packages/react-docgen/src/utils/__tests__/getNameOrValue-test.ts index 6ad2ea07b90..63792d2303c 100644 --- a/packages/react-docgen/src/utils/__tests__/getNameOrValue-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getNameOrValue-test.ts @@ -6,34 +6,35 @@ import type { TypeCastExpression, } from '@babel/types'; import { parse, parseTypescript } from '../../../tests/utils'; -import getNameOrValue from '../getNameOrValue'; +import getNameOrValue from '../getNameOrValue.js'; +import { describe, expect, test } from 'vitest'; describe('getNameOrValue', () => { - it('gets Identifier name', () => { + test('gets Identifier name', () => { expect(getNameOrValue(parse.expression('foo'))).toMatchSnapshot(); }); - it('gets string literal value', () => { + test('gets string literal value', () => { expect(getNameOrValue(parse.expression('"foo"'))).toMatchSnapshot(); }); - it('gets numeric literal value', () => { + test('gets numeric literal value', () => { expect(getNameOrValue(parse.expression('1'))).toMatchSnapshot(); }); - it('gets boolean literal value', () => { + test('gets boolean literal value', () => { expect(getNameOrValue(parse.expression('true'))).toMatchSnapshot(); }); - it('gets null RegExp pattern', () => { + test('gets null RegExp pattern', () => { expect(getNameOrValue(parse.expression('/abc?/'))).toMatchSnapshot(); }); - it('gets null literal value', () => { + test('gets null literal value', () => { expect(getNameOrValue(parse.expression('null'))).toMatchSnapshot(); }); - it('gets TSQualifiedName', () => { + test('gets TSQualifiedName', () => { expect( getNameOrValue( parseTypescript @@ -43,7 +44,7 @@ describe('getNameOrValue', () => { ).toMatchSnapshot(); }); - it('gets QualifiedTypeIdentifier', () => { + test('gets QualifiedTypeIdentifier', () => { expect( getNameOrValue( parse @@ -55,7 +56,7 @@ describe('getNameOrValue', () => { ).toMatchSnapshot(); }); - it('errors on invalid path', () => { + test('errors on invalid path', () => { expect(() => getNameOrValue(parse.statement('function foo(){}')), ).toThrowErrorMatchingSnapshot(); diff --git a/packages/react-docgen/src/utils/__tests__/getParameterName-test.ts b/packages/react-docgen/src/utils/__tests__/getParameterName-test.ts index 20b9a983e67..346ea2b4e0c 100644 --- a/packages/react-docgen/src/utils/__tests__/getParameterName-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getParameterName-test.ts @@ -4,52 +4,53 @@ import type { FunctionExpression, } from '@babel/types'; import { parse } from '../../../tests/utils'; -import getParameterName from '../getParameterName'; +import getParameterName from '../getParameterName.js'; +import { describe, expect, test } from 'vitest'; describe('getParameterName', () => { - it('returns the name for a normal parameter', () => { + test('returns the name for a normal parameter', () => { const def = parse.expression('function(a) {}'); const param = def.get('params')[0]; expect(getParameterName(param)).toEqual('a'); }); - it('returns the name for a rest parameter', () => { + test('returns the name for a rest parameter', () => { const def = parse.expression('function(...a) {}'); const param = def.get('params')[0]; expect(getParameterName(param)).toEqual('...a'); }); - it('returns the name for a parameter with a default value', () => { + test('returns the name for a parameter with a default value', () => { const def = parse.expression('function(a = 0) {}'); const param = def.get('params')[0]; expect(getParameterName(param)).toEqual('a'); }); - it('returns the raw representation for a parameter with object destructuring', () => { + test('returns the raw representation for a parameter with object destructuring', () => { const def = parse.expression('function({a}) {}'); const param = def.get('params')[0]; expect(getParameterName(param)).toEqual('{a}'); }); - it('returns the raw representation for a parameter with array destructuring', () => { + test('returns the raw representation for a parameter with array destructuring', () => { const def = parse.expression('function([a]) {}'); const param = def.get('params')[0]; expect(getParameterName(param)).toEqual('[a]'); }); - it('throws when passed an invalid path', () => { + test('throws when passed an invalid path', () => { // ArrayPattern is wrong, but we test here the throwing, so we are cheating the types const def = parse.expression('function() {}'); expect(() => getParameterName(def)).toThrow(); }); - it('handles typescript param property correctly', () => { + test('handles typescript param property correctly', () => { const def = parse.expression( 'class A { constructor(readonly a: any) {}}', { filename: 'file.ts' }, diff --git a/packages/react-docgen/src/utils/__tests__/getPropType-test.ts b/packages/react-docgen/src/utils/__tests__/getPropType-test.ts index 66c2cf21c15..aed034ccdf5 100644 --- a/packages/react-docgen/src/utils/__tests__/getPropType-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getPropType-test.ts @@ -1,9 +1,10 @@ import type { ExpressionStatement } from '@babel/types'; import { parse, makeMockImporter } from '../../../tests/utils'; -import getPropType from '../getPropType'; +import getPropType from '../getPropType.js'; +import { describe, expect, test } from 'vitest'; describe('getPropType', () => { - it('detects simple prop types', () => { + test('detects simple prop types', () => { const simplePropTypes = [ 'array', 'bool', @@ -39,7 +40,7 @@ describe('getPropType', () => { ); }); - it('detects complex prop types', () => { + test('detects complex prop types', () => { expect(getPropType(parse.expression('oneOf(["foo", "bar"])'))).toEqual({ name: 'enum', value: [ @@ -201,7 +202,7 @@ describe('getPropType', () => { `).get('declaration'), }); - it('resolves variables to their values', () => { + test('resolves variables to their values', () => { const propTypeExpression = parse .statement( ` @@ -214,7 +215,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('resolves imported variables to their values', () => { + test('resolves imported variables to their values', () => { const propTypeExpression = parse .statement( ` @@ -228,7 +229,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('resolves simple identifier to their initialization value', () => { + test('resolves simple identifier to their initialization value', () => { const propTypeIdentifier = parse .statement( ` @@ -241,7 +242,7 @@ describe('getPropType', () => { expect(getPropType(propTypeIdentifier)).toMatchSnapshot(); }); - it('resolves importer identifier to initialization value', () => { + test('resolves importer identifier to initialization value', () => { const propTypeIdentifier = parse .statement( ` @@ -255,7 +256,7 @@ describe('getPropType', () => { expect(getPropType(propTypeIdentifier)).toMatchSnapshot(); }); - it('resolves simple identifier to their initialization value in array', () => { + test('resolves simple identifier to their initialization value in array', () => { const identifierInsideArray = parse .statement( ` @@ -269,7 +270,7 @@ describe('getPropType', () => { expect(getPropType(identifierInsideArray)).toMatchSnapshot(); }); - it('resolves imported identifier to their initialization value in array', () => { + test('resolves imported identifier to their initialization value in array', () => { const identifierInsideArray = parse .statement( ` @@ -284,7 +285,7 @@ describe('getPropType', () => { expect(getPropType(identifierInsideArray)).toMatchSnapshot(); }); - it('resolves memberExpressions', () => { + test('resolves memberExpressions', () => { const propTypeExpression = parse .statement( ` @@ -297,7 +298,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('resolves memberExpressions from imported objects', () => { + test('resolves memberExpressions from imported objects', () => { const propTypeExpression = parse .statement( ` @@ -311,7 +312,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('correctly resolves SpreadElements in arrays', () => { + test('correctly resolves SpreadElements in arrays', () => { const propTypeExpression = parse .statement( ` @@ -324,7 +325,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('correctly resolves SpreadElements in arrays from imported values', () => { + test('correctly resolves SpreadElements in arrays from imported values', () => { const propTypeExpression = parse .statement( ` @@ -338,7 +339,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('correctly resolves nested SpreadElements in arrays', () => { + test('correctly resolves nested SpreadElements in arrays', () => { const propTypeExpression = parse .statement( ` @@ -352,7 +353,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('does resolve object keys values', () => { + test('does resolve object keys values', () => { const propTypeExpression = parse .statement( ` @@ -365,7 +366,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('resolves values from imported Object.keys call', () => { + test('resolves values from imported Object.keys call', () => { const propTypeExpression = parse .statement( ` @@ -379,7 +380,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('does resolve object values', () => { + test('does resolve object values', () => { const propTypeExpression = parse .statement( ` @@ -392,7 +393,7 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('resolves values from imported Object.values call', () => { + test('resolves values from imported Object.values call', () => { const propTypeExpression = parse .statement( ` @@ -406,12 +407,12 @@ describe('getPropType', () => { expect(getPropType(propTypeExpression)).toMatchSnapshot(); }); - it('does not resolve external values without proper importer', () => { + test('does not resolve external values without proper importer', () => { const propTypeExpression = parse .statement( ` PropTypes.oneOf(TYPES); - import { TYPES } from './foo'; + import { TYPES } from './foo.js'; `, ) .get('expression'); @@ -420,15 +421,15 @@ describe('getPropType', () => { }); }); - it('detects custom validation functions for function', () => { + test('detects custom validation functions for function', () => { expect(getPropType(parse.expression('(function() {})'))).toMatchSnapshot(); }); - it('detects custom validation functions for arrow function', () => { + test('detects custom validation functions for arrow function', () => { expect(getPropType(parse.expression('() => {}'))).toMatchSnapshot(); }); - it('detects descriptions on nested types in arrayOf', () => { + test('detects descriptions on nested types in arrayOf', () => { expect( getPropType( parse.expression(`arrayOf( @@ -441,7 +442,7 @@ describe('getPropType', () => { ).toMatchSnapshot(); }); - it('detects descriptions on nested types in objectOf', () => { + test('detects descriptions on nested types in objectOf', () => { expect( getPropType( parse.expression(`objectOf( @@ -454,7 +455,7 @@ describe('getPropType', () => { ).toMatchSnapshot(); }); - it('detects descriptions on nested types in shapes', () => { + test('detects descriptions on nested types in shapes', () => { expect( getPropType( parse.expression(`shape({ @@ -471,7 +472,7 @@ describe('getPropType', () => { ).toMatchSnapshot(); }); - it('detects required notations of nested types in shapes', () => { + test('detects required notations of nested types in shapes', () => { expect( getPropType( parse.expression(`shape({ @@ -482,7 +483,7 @@ describe('getPropType', () => { ).toMatchSnapshot(); }); - it('detects descriptions on nested types in exacts', () => { + test('detects descriptions on nested types in exacts', () => { expect( getPropType( parse.expression(`exact({ @@ -499,7 +500,7 @@ describe('getPropType', () => { ).toMatchSnapshot(); }); - it('detects required notations of nested types in exacts', () => { + test('detects required notations of nested types in exacts', () => { expect( getPropType( parse.expression(`exact({ @@ -510,7 +511,7 @@ describe('getPropType', () => { ).toMatchSnapshot(); }); - it('handles computed properties', () => { + test('handles computed properties', () => { expect( getPropType( parse.expression(`exact({ @@ -521,7 +522,7 @@ describe('getPropType', () => { ).toMatchSnapshot(); }); - it('ignores complex computed properties', () => { + test('ignores complex computed properties', () => { expect( getPropType( parse.expression(`exact({ diff --git a/packages/react-docgen/src/utils/__tests__/getPropertyName-test.ts b/packages/react-docgen/src/utils/__tests__/getPropertyName-test.ts index 2e842c5abc3..2956bc646a1 100644 --- a/packages/react-docgen/src/utils/__tests__/getPropertyName-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getPropertyName-test.ts @@ -1,6 +1,7 @@ import type { ObjectExpression, TypeCastExpression } from '@babel/types'; import { parse, makeMockImporter } from '../../../tests/utils'; -import getPropertyName from '../getPropertyName'; +import getPropertyName from '../getPropertyName.js'; +import { describe, expect, test } from 'vitest'; describe('getPropertyName', () => { const mockImporter = makeMockImporter({ @@ -15,14 +16,14 @@ describe('getPropertyName', () => { `).get('declaration'), }); - it('returns the name for a normal property', () => { + test('returns the name for a normal property', () => { const def = parse.expression('{ foo: 1 }'); const param = def.get('properties')[0]; expect(getPropertyName(param)).toBe('foo'); }); - it('returns the name of a object type spread property', () => { + test('returns the name of a object type spread property', () => { const def = parse.expression('(a: { ...foo })'); const param = def .get('typeAnnotation') @@ -32,7 +33,7 @@ describe('getPropertyName', () => { expect(getPropertyName(param)).toBe('foo'); }); - it('returns the qualified name of a object type spread property', () => { + test('returns the qualified name of a object type spread property', () => { const def = parse.expression('(a: { ...foo.bub })'); const param = def .get('typeAnnotation') @@ -42,42 +43,42 @@ describe('getPropertyName', () => { expect(getPropertyName(param)).toBe('foo.bub'); }); - it('creates name for computed properties', () => { + test('creates name for computed properties', () => { const def = parse.expression('{ [foo]: 21 }'); const param = def.get('properties')[0]; expect(getPropertyName(param)).toBe('@computed#foo'); }); - it('creates name for computed properties from string', () => { + test('creates name for computed properties from string', () => { const def = parse.expression('{ ["foo"]: 21 }'); const param = def.get('properties')[0]; expect(getPropertyName(param)).toBe('foo'); }); - it('creates name for computed properties from int', () => { + test('creates name for computed properties from int', () => { const def = parse.expression('{ [31]: 21 }'); const param = def.get('properties')[0]; expect(getPropertyName(param)).toBe('31'); }); - it('returns null for computed properties from regex', () => { + test('returns null for computed properties from regex', () => { const def = parse.expression('{ [/31/]: 21 }'); const param = def.get('properties')[0]; expect(getPropertyName(param)).toBe(null); }); - it('returns null for to complex computed properties', () => { + test('returns null for to complex computed properties', () => { const def = parse.expression('{ [() => {}]: 21 }'); const param = def.get('properties')[0]; expect(getPropertyName(param)).toBe(null); }); - it('resolves simple variables', () => { + test('resolves simple variables', () => { const def = parse.expressionLast(` const foo = "name"; @@ -88,7 +89,7 @@ describe('getPropertyName', () => { expect(getPropertyName(param)).toBe('name'); }); - it('resolves imported variables', () => { + test('resolves imported variables', () => { const def = parse.expressionLast( ` import foo from 'foo'; @@ -102,7 +103,7 @@ describe('getPropertyName', () => { expect(getPropertyName(param)).toBe('name'); }); - it('resolves simple member expressions', () => { + test('resolves simple member expressions', () => { const def = parse.expressionLast(` const a = { foo: "name" }; @@ -113,7 +114,7 @@ describe('getPropertyName', () => { expect(getPropertyName(param)).toBe('name'); }); - it('resolves imported member expressions', () => { + test('resolves imported member expressions', () => { const def = parse.expressionLast( ` import bar from 'bar'; diff --git a/packages/react-docgen/src/utils/__tests__/getPropertyValuePath-test.ts b/packages/react-docgen/src/utils/__tests__/getPropertyValuePath-test.ts index 313dc548bf9..e15209664e6 100644 --- a/packages/react-docgen/src/utils/__tests__/getPropertyValuePath-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getPropertyValuePath-test.ts @@ -1,14 +1,15 @@ import type { NodePath } from '@babel/traverse'; import type { ExpressionStatement, ObjectExpression } from '@babel/types'; import { parse, makeMockImporter } from '../../../tests/utils'; -import getPropertyValuePath from '../getPropertyValuePath'; +import getPropertyValuePath from '../getPropertyValuePath.js'; +import { describe, expect, test } from 'vitest'; describe('getPropertyValuePath', () => { const mockImporter = makeMockImporter({ bar: stmt => stmt(`export default 'bar';`).get('declaration'), }); - it('returns the value path if the property exists', () => { + test('returns the value path if the property exists', () => { const objectExpressionPath = parse .statement('({foo: 21, bar: 42})') .get('expression') as NodePath; @@ -18,7 +19,7 @@ describe('getPropertyValuePath', () => { ); }); - it('returns the value path for a computed property in scope', () => { + test('returns the value path for a computed property in scope', () => { const objectExpressionPath = parse .statement( ` @@ -33,7 +34,7 @@ describe('getPropertyValuePath', () => { ); }); - it('returns undefined if the property does not exist', () => { + test('returns undefined if the property does not exist', () => { const objectExpressionPath = parse .statement('({foo: 21, bar: 42})') .get('expression') as NodePath; @@ -41,7 +42,7 @@ describe('getPropertyValuePath', () => { expect(getPropertyValuePath(objectExpressionPath, 'baz')).toBeNull(); }); - it('returns the value path for a computed property that was imported', () => { + test('returns the value path for a computed property that was imported', () => { const objectExpressionPath = parse .statement( ` @@ -57,7 +58,7 @@ describe('getPropertyValuePath', () => { ); }); - it('returns ObjectMethod directly', () => { + test('returns ObjectMethod directly', () => { const objectExpressionPath = parse .statement('({ foo(){} })') .get('expression') as NodePath; diff --git a/packages/react-docgen/src/utils/__tests__/getTSType-test.ts b/packages/react-docgen/src/utils/__tests__/getTSType-test.ts index 3b4acf63c85..710eb09b690 100644 --- a/packages/react-docgen/src/utils/__tests__/getTSType-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getTSType-test.ts @@ -13,7 +13,8 @@ import { noopImporter, } from '../../../tests/utils'; import type { Importer } from '../../importer'; -import getTSType from '../getTSType'; +import getTSType from '../getTSType.js'; +import { describe, expect, test } from 'vitest'; function typeAlias( stmt: string, @@ -87,7 +88,7 @@ const mockImporter = makeMockImporter({ }); describe('getTSType', () => { - it('detects simple types', () => { + test('detects simple types', () => { const simplePropTypes = [ 'string', 'number', @@ -117,7 +118,7 @@ describe('getTSType', () => { const literalTypes = ['"foo"', 1234, true, -1, '`foo`']; literalTypes.forEach(value => { - it(`detects ${value}`, () => { + test(`detects ${value}`, () => { const typePath = typeAlias(`let x: ${value};`); expect(getTSType(typePath)).toMatchSnapshot(); @@ -125,13 +126,13 @@ describe('getTSType', () => { }); }); - it('detects external type', () => { + test('detects external type', () => { const typePath = typeAlias('let x: xyz;'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves external type', () => { + test('resolves external type', () => { const typePath = typeAlias( ` let x: xyz; @@ -143,25 +144,25 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects array type shorthand', () => { + test('detects array type shorthand', () => { const typePath = typeAlias('let x: number[];'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects array type', () => { + test('detects array type', () => { const typePath = typeAlias('let x: Array;'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects array type with multiple types', () => { + test('detects array type with multiple types', () => { const typePath = typeAlias('let x: Array;'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported types used for arrays', () => { + test('resolves imported types used for arrays', () => { let typePath = typeAlias( ` let x: xyz[]; @@ -191,13 +192,13 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects class type', () => { + test('detects class type', () => { const typePath = typeAlias('let x: Class;'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported subtype for class type', () => { + test('resolves imported subtype for class type', () => { const typePath = typeAlias( ` let x: Class; @@ -209,13 +210,13 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects function type with subtype', () => { + test('detects function type with subtype', () => { const typePath = typeAlias('let x: Function;'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported subtype for function type', () => { + test('resolves imported subtype for function type', () => { const typePath = typeAlias( ` let x: Function; @@ -227,13 +228,13 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects object types', () => { + test('detects object types', () => { const typePath = typeAlias('let x: { a: string, b?: xyz };'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported types for object property types', () => { + test('resolves imported types for object property types', () => { const typePath = typeAlias( ` let x: { a: number, b?: xyz }; @@ -245,13 +246,13 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects union type', () => { + test('detects union type', () => { const typePath = typeAlias('let x: string | xyz | "foo" | void;'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported types within union type', () => { + test('resolves imported types within union type', () => { const typePath = typeAlias( ` let x: string | barbaz | "foo" | void; @@ -263,13 +264,13 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects intersection type', () => { + test('detects intersection type', () => { const typePath = typeAlias('let x: string & xyz & "foo" & void;'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported types within intersection type', () => { + test('resolves imported types within intersection type', () => { const typePath = typeAlias( ` let x: string & barbaz & "foo" & void; @@ -281,7 +282,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects function signature type', () => { + test('detects function signature type', () => { const typePath = typeAlias( 'let x: (p1: number, p2: string, ...rest: Array) => boolean;', ); @@ -289,13 +290,13 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects function signature type with `this` parameter', () => { + test('detects function signature type with `this` parameter', () => { const typePath = typeAlias('let x: (this: Foo, p1: number) => boolean;'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects callable signature type', () => { + test('detects callable signature type', () => { const typePath = typeAlias( 'let x: { (str: string): string, token: string };', ); @@ -303,7 +304,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves function signature types with imported types', () => { + test('resolves function signature types with imported types', () => { let typePath = typeAlias( ` let x: (p1: abc, p2: xyz, ...rest: Array) => def; @@ -339,7 +340,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects map signature', () => { + test('detects map signature', () => { const typePath = typeAlias( 'let x: { [key: string]: number, [key: "xl"]: string, token: "a" | "b" };', ); @@ -347,7 +348,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported types in map signature', () => { + test('resolves imported types in map signature', () => { const typePath = typeAlias( ` let x: { [key: xyz]: abc, [key: "xl"]: xyz, token: barbaz }; @@ -361,19 +362,19 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects tuple signature', () => { + test('detects tuple signature', () => { const typePath = typeAlias('let x: [string, number];'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects tuple in union signature', () => { + test('detects tuple in union signature', () => { const typePath = typeAlias('let x: [string, number] | [number, string];'); expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported types in tuple signatures', () => { + test('resolves imported types in tuple signatures', () => { let typePath = typeAlias( ` let x: [xyz, abc]; @@ -397,7 +398,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('detects indexed access', () => { + test('detects indexed access', () => { const typePath = typeAlias(` var x: A["x"] = 2; @@ -407,7 +408,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves indexed access', () => { + test('resolves indexed access', () => { const typePath = typeAlias(` var x: A["x"] = 2; @@ -417,7 +418,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves indexed access of array', () => { + test('resolves indexed access of array', () => { const typePath = parseTypescript .statement( ` @@ -438,7 +439,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('can resolve indexed access to imported type', () => { + test('can resolve indexed access to imported type', () => { const typePath = typeAlias( ` var x: A["x"] = 2; @@ -450,7 +451,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves types in scope', () => { + test('resolves types in scope', () => { const typePath = typeAlias(` var x: MyType = 2; @@ -460,7 +461,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('handles typeof types', () => { + test('handles typeof types', () => { const typePath = typeAlias(` var x: typeof MyType = {}; @@ -470,7 +471,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves typeof of imported types', () => { + test('resolves typeof of imported types', () => { const typePath = typeAlias( ` var x: typeof MyType = {}; @@ -482,7 +483,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('handles qualified type identifiers', () => { + test('handles qualified type identifiers', () => { const typePath = typeAlias(` var x: MyType.x = {}; @@ -492,7 +493,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('handles qualified type identifiers with params', () => { + test('handles qualified type identifiers with params', () => { const typePath = typeAlias(` var x: MyType.x = {}; @@ -502,7 +503,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('handles generic types', () => { + test('handles generic types', () => { const typePath = typeAlias(` var x: MyType = {}; @@ -512,7 +513,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported types that need subtypes', () => { + test('resolves imported types that need subtypes', () => { const typePath = typeAlias( ` var x: MyGenericType = {}; @@ -524,7 +525,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('handles mapped types', () => { + test('handles mapped types', () => { const typePath = typeAlias(` var x: { [key in 'x' | 'y']: boolean}; `); @@ -532,7 +533,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves imported types applied to mapped types', () => { + test('resolves imported types applied to mapped types', () => { const typePath = typeAlias( ` var x: { [key in barbaz]: boolean}; @@ -559,7 +560,7 @@ describe('getTSType', () => { ]; types.forEach(type => { - it(type, () => { + test(type, () => { const typePath = typeAlias(` var x: ${type} = 2; @@ -571,7 +572,7 @@ describe('getTSType', () => { }); }); - it('resolves keyof to union', () => { + test('resolves keyof to union', () => { const typePath = typeAlias(` var x: keyof typeof CONTENTS = 2; const CONTENTS = { @@ -583,7 +584,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves keyof with imported types', () => { + test('resolves keyof with imported types', () => { const typePath = typeAlias( ` var x: keyof typeof CONTENTS = 2; @@ -595,7 +596,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('resolves keyof with inline object to union', () => { + test('resolves keyof with inline object to union', () => { const typePath = typeAlias(` var x: keyof { apple: string, banana: string } = 2; `); @@ -603,7 +604,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('handles multiple references to one type', () => { + test('handles multiple references to one type', () => { const typePath = typeAlias(` let action: { a: Action, b: Action }; type Action = {}; @@ -612,7 +613,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('handles generics of the same Name', () => { + test('handles generics of the same Name', () => { const typePath = parseTypescript .statement( ` @@ -630,7 +631,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('handles self-referencing type cycles', () => { + test('handles self-referencing type cycles', () => { const typePath = typeAlias(` let action: Action; type Action = { subAction: Action }; @@ -639,7 +640,7 @@ describe('getTSType', () => { expect(getTSType(typePath)).toMatchSnapshot(); }); - it('handles long type cycles', () => { + test('handles long type cycles', () => { const typePath = typeAlias(` let action: Action; type Action = { subAction: SubAction }; diff --git a/packages/react-docgen/src/utils/__tests__/getTypeAnnotation-test.ts b/packages/react-docgen/src/utils/__tests__/getTypeAnnotation-test.ts index b52cafd4feb..c45ca428e30 100644 --- a/packages/react-docgen/src/utils/__tests__/getTypeAnnotation-test.ts +++ b/packages/react-docgen/src/utils/__tests__/getTypeAnnotation-test.ts @@ -1,9 +1,10 @@ import type { TypeCastExpression } from '@babel/types'; import { parse } from '../../../tests/utils'; -import getTypeAnnotation from '../getTypeAnnotation'; +import getTypeAnnotation from '../getTypeAnnotation.js'; +import { describe, expect, test } from 'vitest'; describe('getTypeAnnotation', () => { - it('detects simple type', () => { + test('detects simple type', () => { const path = parse.expression('x: xyz'); expect(getTypeAnnotation(path)).toEqual( @@ -11,13 +12,13 @@ describe('getTypeAnnotation', () => { ); }); - it('does not fail if no type', () => { + test('does not fail if no type', () => { const path = parse.expression('x = 0'); expect(getTypeAnnotation(path)).toEqual(null); }); - it('stops at first nested type', () => { + test('stops at first nested type', () => { const path = parse.expression('x: ?xyz'); expect(getTypeAnnotation(path)).toEqual( diff --git a/packages/react-docgen/src/utils/__tests__/isDestructuringAssignment-test.ts b/packages/react-docgen/src/utils/__tests__/isDestructuringAssignment-test.ts index d39d15dff31..46ab379a3b0 100644 --- a/packages/react-docgen/src/utils/__tests__/isDestructuringAssignment-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isDestructuringAssignment-test.ts @@ -1,10 +1,11 @@ import type { NodePath } from '@babel/traverse'; import type { Node } from '@babel/types'; import { parse } from '../../../tests/utils'; -import isDestructuringAssignment from '../isDestructuringAssignment'; +import isDestructuringAssignment from '../isDestructuringAssignment.js'; +import { describe, expect, test } from 'vitest'; describe('isDestructuringAssignment', () => { - it('detects destructuring', () => { + test('detects destructuring', () => { const def = parse(` var { Component } = require('react'); `).get('body.0.declarations.0.id.properties.0') as NodePath; @@ -12,7 +13,7 @@ describe('isDestructuringAssignment', () => { expect(isDestructuringAssignment(def, 'Component')).toBe(true); }); - it('fails if name does not match', () => { + test('fails if name does not match', () => { const def = parse(` var { Component } = require('react'); `).get('body.0.declarations.0.id.properties.0') as NodePath; @@ -20,7 +21,7 @@ describe('isDestructuringAssignment', () => { expect(isDestructuringAssignment(def, 'Component2')).toBe(false); }); - it('detects destructuring with alias', () => { + test('detects destructuring with alias', () => { const def = parse(` var { Component: C } = require('react'); `).get('body.0.declarations.0.id.properties.0') as NodePath; @@ -28,7 +29,7 @@ describe('isDestructuringAssignment', () => { expect(isDestructuringAssignment(def, 'Component')).toBe(true); }); - it('fails if name does not match with alias', () => { + test('fails if name does not match with alias', () => { const def = parse(` var { Component: C } = require('react'); `).get('body.0.declarations.0.id.properties.0') as NodePath; diff --git a/packages/react-docgen/src/utils/__tests__/isExportsOrModuleAssignment-test.ts b/packages/react-docgen/src/utils/__tests__/isExportsOrModuleAssignment-test.ts index a80453db807..e36e6b1dc2f 100644 --- a/packages/react-docgen/src/utils/__tests__/isExportsOrModuleAssignment-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isExportsOrModuleAssignment-test.ts @@ -1,20 +1,21 @@ import { parse } from '../../../tests/utils'; -import isExportsOrModuleAssignment from '../isExportsOrModuleAssignment'; +import isExportsOrModuleAssignment from '../isExportsOrModuleAssignment.js'; +import { describe, expect, test } from 'vitest'; describe('isExportsOrModuleAssignment', () => { - it('detects "module.exports = ...;"', () => { + test('detects "module.exports = ...;"', () => { expect( isExportsOrModuleAssignment(parse.statement('module.exports = foo;')), ).toBe(true); }); - it('detects "exports.foo = ..."', () => { + test('detects "exports.foo = ..."', () => { expect( isExportsOrModuleAssignment(parse.statement('exports.foo = foo;')), ).toBe(true); }); - it('does not accept "exports = foo;"', () => { + test('does not accept "exports = foo;"', () => { // That doesn't actually export anything expect(isExportsOrModuleAssignment(parse.statement('exports = foo;'))).toBe( false, diff --git a/packages/react-docgen/src/utils/__tests__/isReactCloneElementCall-test.ts b/packages/react-docgen/src/utils/__tests__/isReactCloneElementCall-test.ts index dfd0b5c0bcc..6d84dc387e0 100644 --- a/packages/react-docgen/src/utils/__tests__/isReactCloneElementCall-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isReactCloneElementCall-test.ts @@ -1,5 +1,6 @@ import { parse, makeMockImporter } from '../../../tests/utils'; -import isReactCloneElementCall from '../isReactCloneElementCall'; +import isReactCloneElementCall from '../isReactCloneElementCall.js'; +import { describe, expect, test } from 'vitest'; describe('isReactCloneElementCall', () => { const mockImporter = makeMockImporter({ @@ -11,7 +12,7 @@ describe('isReactCloneElementCall', () => { }); describe('built in React.createClass', () => { - it('accepts cloneElement called on React', () => { + test('accepts cloneElement called on React', () => { const def = parse.expressionLast(` var React = require("React"); React.cloneElement({}); @@ -20,7 +21,7 @@ describe('isReactCloneElementCall', () => { expect(isReactCloneElementCall(def)).toBe(true); }); - it('accepts cloneElement called on aliased React', () => { + test('accepts cloneElement called on aliased React', () => { const def = parse.expressionLast(` var other = require("React"); other.cloneElement({}); @@ -29,7 +30,7 @@ describe('isReactCloneElementCall', () => { expect(isReactCloneElementCall(def)).toBe(true); }); - it('ignores other React calls', () => { + test('ignores other React calls', () => { const def = parse.expressionLast(` var React = require("React"); React.isValidElement({}); @@ -38,7 +39,7 @@ describe('isReactCloneElementCall', () => { expect(isReactCloneElementCall(def)).toBe(false); }); - it('ignores non React calls to cloneElement', () => { + test('ignores non React calls to cloneElement', () => { const def = parse.expressionLast(` var React = require("bob"); React.cloneElement({}); @@ -47,7 +48,7 @@ describe('isReactCloneElementCall', () => { expect(isReactCloneElementCall(def)).toBe(false); }); - it('accepts cloneElement called on destructed value', () => { + test('accepts cloneElement called on destructed value', () => { const def = parse.expressionLast(` var { cloneElement } = require("react"); cloneElement({}); @@ -56,7 +57,7 @@ describe('isReactCloneElementCall', () => { expect(isReactCloneElementCall(def)).toBe(true); }); - it('accepts cloneElement called on destructed aliased value', () => { + test('accepts cloneElement called on destructed aliased value', () => { const def = parse.expressionLast(` var { cloneElement: foo } = require("react"); foo({}); @@ -65,7 +66,7 @@ describe('isReactCloneElementCall', () => { expect(isReactCloneElementCall(def)).toBe(true); }); - it('accepts cloneElement called on imported value', () => { + test('accepts cloneElement called on imported value', () => { const def = parse.expressionLast(` import { cloneElement } from "react"; cloneElement({}); @@ -74,7 +75,7 @@ describe('isReactCloneElementCall', () => { expect(isReactCloneElementCall(def)).toBe(true); }); - it('accepts cloneElement called on imported aliased value', () => { + test('accepts cloneElement called on imported aliased value', () => { const def = parse.expressionLast(` import { cloneElement as foo } from "react"; foo({}); @@ -83,7 +84,7 @@ describe('isReactCloneElementCall', () => { expect(isReactCloneElementCall(def)).toBe(true); }); - it('can resolve cloneElement imported from an intermediate module', () => { + test('can resolve cloneElement imported from an intermediate module', () => { const def = parse.expressionLast( ` import foo from "foo"; diff --git a/packages/react-docgen/src/utils/__tests__/isReactComponentClass-test.ts b/packages/react-docgen/src/utils/__tests__/isReactComponentClass-test.ts index 4d4e1e69655..b8032ac789d 100644 --- a/packages/react-docgen/src/utils/__tests__/isReactComponentClass-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isReactComponentClass-test.ts @@ -1,5 +1,6 @@ import { parse, makeMockImporter } from '../../../tests/utils'; -import isReactComponentClass from '../isReactComponentClass'; +import isReactComponentClass from '../isReactComponentClass.js'; +import { describe, expect, test } from 'vitest'; describe('isReactComponentClass', () => { const mockImporter = makeMockImporter({ @@ -17,31 +18,31 @@ describe('isReactComponentClass', () => { }); describe('render method', () => { - it('ignores class declarations with a render method without superclass', () => { + test('ignores class declarations with a render method without superclass', () => { const def = parse.statement('class Foo { render() {}}'); expect(isReactComponentClass(def)).toBe(false); }); - it('ignores class expression with a render method without superclass', () => { + test('ignores class expression with a render method without superclass', () => { const def = parse.expression('class { render() {}}'); expect(isReactComponentClass(def)).toBe(false); }); - it('ignores static render methods', () => { + test('ignores static render methods', () => { const def = parse.statement('class Foo { static render() {}}'); expect(isReactComponentClass(def)).toBe(false); }); - it('ignores dynamic render methods', () => { + test('ignores dynamic render methods', () => { const def = parse.statement('class Foo { static [render]() {}}'); expect(isReactComponentClass(def)).toBe(false); }); - it('ignores getter or setter render methods', () => { + test('ignores getter or setter render methods', () => { let def = parse.statement('class Foo { get render() {}}'); expect(isReactComponentClass(def)).toBe(false); @@ -52,7 +53,7 @@ describe('isReactComponentClass', () => { }); describe('JSDoc @extends React.Component', () => { - it('accepts class declarations declaring `@extends React.Component` in JSDoc', () => { + test('accepts class declarations declaring `@extends React.Component` in JSDoc', () => { const def = parse.statementLast(` var React = require('react'); /** @@ -67,7 +68,7 @@ describe('isReactComponentClass', () => { }); describe('React.Component inheritance', () => { - it('accepts class declarations extending React.Component', () => { + test('accepts class declarations extending React.Component', () => { const def = parse.statementLast(` var React = require('react'); class Foo extends React.Component {} @@ -76,7 +77,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(true); }); - it('accepts class expressions extending React.Component', () => { + test('accepts class expressions extending React.Component', () => { const def = parse .statementLast( ` @@ -90,7 +91,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(true); }); - it('resolves the super class reference', () => { + test('resolves the super class reference', () => { const def = parse.statementLast(` var { Component } = require('react'); var C = Component; @@ -100,7 +101,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(true); }); - it('resolves the super class reference with alias', () => { + test('resolves the super class reference with alias', () => { const def = parse.statementLast(` var { Component: C } = require('react'); class Foo extends C {} @@ -109,7 +110,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(true); }); - it('does not accept references to other modules', () => { + test('does not accept references to other modules', () => { const def = parse.statementLast( ` var { Component } = require('FakeReact'); @@ -120,7 +121,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(false); }); - it('does not consider super class if render method is present', () => { + test('does not consider super class if render method is present', () => { const def = parse.statementLast( ` var {Component} = require('FakeReact'); @@ -131,7 +132,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(true); }); - it('can resolve Component from an intermediate module', () => { + test('can resolve Component from an intermediate module', () => { const def = parse.statementLast( `import RC from 'component'; class Foo extends RC {}`, @@ -143,7 +144,7 @@ describe('isReactComponentClass', () => { }); describe('React.PureComponent inheritance', () => { - it('accepts class declarations extending React.PureComponent', () => { + test('accepts class declarations extending React.PureComponent', () => { const def = parse.statementLast( `var React = require('react'); class Foo extends React.PureComponent {}`, @@ -152,7 +153,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(true); }); - it('accepts class expressions extending React.PureComponent', () => { + test('accepts class expressions extending React.PureComponent', () => { const def = parse .statementLast( `var React = require('react'); @@ -164,7 +165,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(true); }); - it('resolves the super class reference', () => { + test('resolves the super class reference', () => { const def = parse.statementLast( `var {PureComponent} = require('react'); var C = PureComponent; @@ -174,7 +175,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(true); }); - it('does not accept references to other modules', () => { + test('does not accept references to other modules', () => { const def = parse.statementLast( `var {PureComponent} = require('FakeReact'); class Foo extends PureComponent {}`, @@ -183,7 +184,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(false); }); - it('does not consider super class if render method is present', () => { + test('does not consider super class if render method is present', () => { const def = parse.statementLast(` var {PureComponent} = require('FakeReact'); class Foo extends PureComponent { render() {} } @@ -192,7 +193,7 @@ describe('isReactComponentClass', () => { expect(isReactComponentClass(def)).toBe(true); }); - it('can resolve PureComponent from an intermediate module', () => { + test('can resolve PureComponent from an intermediate module', () => { const def = parse.statementLast( ` import PC from 'pureComponent'; diff --git a/packages/react-docgen/src/utils/__tests__/isReactComponentMethod-test.ts b/packages/react-docgen/src/utils/__tests__/isReactComponentMethod-test.ts index 6a35cda8e79..3aeab748acf 100644 --- a/packages/react-docgen/src/utils/__tests__/isReactComponentMethod-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isReactComponentMethod-test.ts @@ -1,6 +1,7 @@ import type { ClassDeclaration, ObjectExpression } from '@babel/types'; import { parse, makeMockImporter } from '../../../tests/utils'; -import isReactComponentMethod from '../isReactComponentMethod'; +import isReactComponentMethod from '../isReactComponentMethod.js'; +import { describe, expect, test } from 'vitest'; describe('isReactComponentMethod', () => { const mockImporter = makeMockImporter({ @@ -10,41 +11,41 @@ describe('isReactComponentMethod', () => { `).get('declaration'), }); - it('returns true if the method is a component class method', () => { + test('returns true if the method is a component class method', () => { const def = parse.statement('class Foo { render() {}}'); const method = def.get('body').get('body')[0]; expect(isReactComponentMethod(method)).toBe(true); }); - it('returns true if the method is a component `createClass` object method', () => { + test('returns true if the method is a component `createClass` object method', () => { const def = parse.expression('{ render() {}}'); const method = def.get('properties')[0]; expect(isReactComponentMethod(method)).toBe(true); }); - it('returns false if the method is not a component class method', () => { + test('returns false if the method is not a component class method', () => { const def = parse.statement('class Foo { bar() {}}'); const method = def.get('body').get('body')[0]; expect(isReactComponentMethod(method)).toBe(false); }); - it('returns false if the method is not a component `createClass` object method', () => { + test('returns false if the method is not a component `createClass` object method', () => { const def = parse.expression('{ bar() {}}'); const method = def.get('properties')[0]; expect(isReactComponentMethod(method)).toBe(false); }); - it('returns false if the path is not a method or object property', () => { + test('returns false if the path is not a method or object property', () => { const def = parse.statement('let foo = "bar";'); expect(isReactComponentMethod(def)).toBe(false); }); - it('resolves imported value of computed property', () => { + test('resolves imported value of computed property', () => { const def = parse.statement( ` class Foo { [foo]() {}} diff --git a/packages/react-docgen/src/utils/__tests__/isReactCreateClassCall-test.ts b/packages/react-docgen/src/utils/__tests__/isReactCreateClassCall-test.ts index 73566f5b1ef..135090e2209 100644 --- a/packages/react-docgen/src/utils/__tests__/isReactCreateClassCall-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isReactCreateClassCall-test.ts @@ -1,5 +1,6 @@ import { parse, makeMockImporter } from '../../../tests/utils'; -import isReactCreateClassCall from '../isReactCreateClassCall'; +import isReactCreateClassCall from '../isReactCreateClassCall.js'; +import { describe, expect, test } from 'vitest'; describe('isReactCreateClassCall', () => { const mockImporter = makeMockImporter({ @@ -17,7 +18,7 @@ describe('isReactCreateClassCall', () => { }); describe('built in React.createClass', () => { - it('accepts createClass called on React', () => { + test('accepts createClass called on React', () => { const def = parse.expressionLast(` var React = require("React"); React.createClass({ @@ -28,7 +29,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(true); }); - it('accepts createClass called on aliased React', () => { + test('accepts createClass called on aliased React', () => { const def = parse.expressionLast(` var other = require("React"); other.createClass({ @@ -39,7 +40,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(true); }); - it('ignores other React calls', () => { + test('ignores other React calls', () => { const def = parse.expressionLast(` var React = require("React"); React.isValidElement({}); @@ -48,7 +49,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(false); }); - it('ignores non React calls to createClass', () => { + test('ignores non React calls to createClass', () => { const def = parse.expressionLast(` var React = require("bob"); React.createClass({ @@ -59,7 +60,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(false); }); - it('accepts createClass called on destructed value', () => { + test('accepts createClass called on destructed value', () => { const def = parse.expressionLast(` var { createClass } = require("react"); createClass({}); @@ -68,7 +69,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(true); }); - it('accepts createClass called on destructed aliased value', () => { + test('accepts createClass called on destructed aliased value', () => { const def = parse.expressionLast(` var { createClass: foo } = require("react"); foo({}); @@ -77,7 +78,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(true); }); - it('accepts createClass called on imported value', () => { + test('accepts createClass called on imported value', () => { const def = parse.expressionLast(` import { createClass } from "react"; createClass({}); @@ -86,7 +87,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(true); }); - it('accepts createClass called on imported aliased value', () => { + test('accepts createClass called on imported aliased value', () => { const def = parse.expressionLast(` import { createClass as foo } from "react"; foo({}); @@ -95,7 +96,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(true); }); - it('resolves createClass imported from intermediate module', () => { + test('resolves createClass imported from intermediate module', () => { const def = parse.expressionLast( ` import foo from "foo"; @@ -109,7 +110,7 @@ describe('isReactCreateClassCall', () => { }); describe('modular in create-react-class', () => { - it('accepts create-react-class', () => { + test('accepts create-react-class', () => { const def = parse.expressionLast(` var createReactClass = require("create-react-class"); createReactClass({ @@ -120,7 +121,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(true); }); - it('accepts create-react-class calls on another name', () => { + test('accepts create-react-class calls on another name', () => { const def = parse.expressionLast(` var makeClass = require("create-react-class"); makeClass({ @@ -131,7 +132,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(true); }); - it('ignores non create-react-class calls to createReactClass', () => { + test('ignores non create-react-class calls to createReactClass', () => { const def = parse.expressionLast(` var createReactClass = require("bob"); createReactClass({ @@ -142,7 +143,7 @@ describe('isReactCreateClassCall', () => { expect(isReactCreateClassCall(def)).toBe(false); }); - it('resolves create-react-class imported from intermediate module', () => { + test('resolves create-react-class imported from intermediate module', () => { const def = parse.expressionLast( ` import bar from "bar"; diff --git a/packages/react-docgen/src/utils/__tests__/isReactCreateElementCall-test.ts b/packages/react-docgen/src/utils/__tests__/isReactCreateElementCall-test.ts index 5b3f46d67f4..dce684d6a2c 100644 --- a/packages/react-docgen/src/utils/__tests__/isReactCreateElementCall-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isReactCreateElementCall-test.ts @@ -1,5 +1,6 @@ import { parse, makeMockImporter } from '../../../tests/utils'; -import isReactCreateElementCall from '../isReactCreateElementCall'; +import isReactCreateElementCall from '../isReactCreateElementCall.js'; +import { describe, expect, test } from 'vitest'; describe('isReactCreateElementCall', () => { const mockImporter = makeMockImporter({ @@ -11,7 +12,7 @@ describe('isReactCreateElementCall', () => { }); describe('built in React.createElement', () => { - it('accepts createElement called on React', () => { + test('accepts createElement called on React', () => { const def = parse.expressionLast(` var React = require("React"); React.createElement({ @@ -22,7 +23,7 @@ describe('isReactCreateElementCall', () => { expect(isReactCreateElementCall(def)).toBe(true); }); - it('accepts createElement called on aliased React', () => { + test('accepts createElement called on aliased React', () => { const def = parse.expressionLast(` var other = require("React"); other.createElement({ @@ -33,7 +34,7 @@ describe('isReactCreateElementCall', () => { expect(isReactCreateElementCall(def)).toBe(true); }); - it('ignores other React calls', () => { + test('ignores other React calls', () => { const def = parse.expressionLast(` var React = require("React"); React.isValidElement({}); @@ -42,7 +43,7 @@ describe('isReactCreateElementCall', () => { expect(isReactCreateElementCall(def)).toBe(false); }); - it('ignores non React calls to createElement', () => { + test('ignores non React calls to createElement', () => { const def = parse.expressionLast(` var React = require("bob"); React.createElement({ @@ -53,7 +54,7 @@ describe('isReactCreateElementCall', () => { expect(isReactCreateElementCall(def)).toBe(false); }); - it('accepts createElement called on destructed value', () => { + test('accepts createElement called on destructed value', () => { const def = parse.expressionLast(` var { createElement } = require("react"); createElement({}); @@ -62,7 +63,7 @@ describe('isReactCreateElementCall', () => { expect(isReactCreateElementCall(def)).toBe(true); }); - it('accepts createElement called on destructed aliased value', () => { + test('accepts createElement called on destructed aliased value', () => { const def = parse.expressionLast(` var { createElement: foo } = require("react"); foo({}); @@ -71,7 +72,7 @@ describe('isReactCreateElementCall', () => { expect(isReactCreateElementCall(def)).toBe(true); }); - it('accepts createElement called on imported value', () => { + test('accepts createElement called on imported value', () => { const def = parse.expressionLast(` import { createElement } from "react"; createElement({}); @@ -80,7 +81,7 @@ describe('isReactCreateElementCall', () => { expect(isReactCreateElementCall(def)).toBe(true); }); - it('accepts createElement called on imported aliased value', () => { + test('accepts createElement called on imported aliased value', () => { const def = parse.expressionLast(` import { createElement as foo } from "react"; foo({}); @@ -89,7 +90,7 @@ describe('isReactCreateElementCall', () => { expect(isReactCreateElementCall(def)).toBe(true); }); - it('can resolve createElement imported from an intermediate module', () => { + test('can resolve createElement imported from an intermediate module', () => { const def = parse.expressionLast( `import foo from "foo"; foo({});`, diff --git a/packages/react-docgen/src/utils/__tests__/isReactForwardRefCall-test.ts b/packages/react-docgen/src/utils/__tests__/isReactForwardRefCall-test.ts index 63b201dcc44..175583a0526 100644 --- a/packages/react-docgen/src/utils/__tests__/isReactForwardRefCall-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isReactForwardRefCall-test.ts @@ -1,5 +1,6 @@ import { makeMockImporter, parse } from '../../../tests/utils'; -import isReactForwardRefCall from '../isReactForwardRefCall'; +import isReactForwardRefCall from '../isReactForwardRefCall.js'; +import { describe, expect, test } from 'vitest'; describe('isReactForwardRefCall', () => { const mockImporter = makeMockImporter({ @@ -11,7 +12,7 @@ describe('isReactForwardRefCall', () => { }); describe('built in React.forwardRef', () => { - it('accepts forwardRef called on React', () => { + test('accepts forwardRef called on React', () => { const def = parse.expressionLast(` var React = require("React"); React.forwardRef({ @@ -22,7 +23,7 @@ describe('isReactForwardRefCall', () => { expect(isReactForwardRefCall(def)).toBe(true); }); - it('accepts forwardRef called on aliased React', () => { + test('accepts forwardRef called on aliased React', () => { const def = parse.expressionLast(` var other = require("React"); other.forwardRef({ @@ -33,7 +34,7 @@ describe('isReactForwardRefCall', () => { expect(isReactForwardRefCall(def)).toBe(true); }); - it('ignores other React calls', () => { + test('ignores other React calls', () => { const def = parse.expressionLast(` var React = require("React"); React.isValidElement({}); @@ -42,7 +43,7 @@ describe('isReactForwardRefCall', () => { expect(isReactForwardRefCall(def)).toBe(false); }); - it('ignores non React calls to forwardRef', () => { + test('ignores non React calls to forwardRef', () => { const def = parse.expressionLast(` var React = require("bob"); React.forwardRef({ @@ -53,7 +54,7 @@ describe('isReactForwardRefCall', () => { expect(isReactForwardRefCall(def)).toBe(false); }); - it('accepts forwardRef called on destructed value', () => { + test('accepts forwardRef called on destructed value', () => { const def = parse.expressionLast(` var { forwardRef } = require("react"); forwardRef({}); @@ -62,7 +63,7 @@ describe('isReactForwardRefCall', () => { expect(isReactForwardRefCall(def)).toBe(true); }); - it('accepts forwardRef called on destructed aliased value', () => { + test('accepts forwardRef called on destructed aliased value', () => { const def = parse.expressionLast(` var { forwardRef: foo } = require("react"); foo({}); @@ -71,7 +72,7 @@ describe('isReactForwardRefCall', () => { expect(isReactForwardRefCall(def)).toBe(true); }); - it('accepts forwardRef called on imported value', () => { + test('accepts forwardRef called on imported value', () => { const def = parse.expressionLast(` import { forwardRef } from "react"; forwardRef({}); @@ -80,7 +81,7 @@ describe('isReactForwardRefCall', () => { expect(isReactForwardRefCall(def)).toBe(true); }); - it('does not accept forwardRef if not outer call', () => { + test('does not accept forwardRef if not outer call', () => { const def = parse.expressionLast(` import { forwardRef, memo } from "react"; memo(forwardRef({})); @@ -89,7 +90,7 @@ describe('isReactForwardRefCall', () => { expect(isReactForwardRefCall(def)).toBe(false); }); - it('accepts forwardRef called on imported aliased value', () => { + test('accepts forwardRef called on imported aliased value', () => { const def = parse.expressionLast(` import { forwardRef as foo } from "react"; foo({}); @@ -98,7 +99,7 @@ describe('isReactForwardRefCall', () => { expect(isReactForwardRefCall(def)).toBe(true); }); - it('can resolve forwardRef imported from an intermediate module', () => { + test('can resolve forwardRef imported from an intermediate module', () => { const def = parse.expressionLast( ` import foo from "foo"; diff --git a/packages/react-docgen/src/utils/__tests__/isReactModuleName-test.ts b/packages/react-docgen/src/utils/__tests__/isReactModuleName-test.ts index f755c44db11..11fbd43611b 100644 --- a/packages/react-docgen/src/utils/__tests__/isReactModuleName-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isReactModuleName-test.ts @@ -1,4 +1,5 @@ -import isReactModuleName from '../isReactModuleName'; +import isReactModuleName from '../isReactModuleName.js'; +import { describe, expect, test } from 'vitest'; describe('isReactModuleName', () => { const reactModules = [ @@ -10,12 +11,12 @@ describe('isReactModuleName', () => { ]; reactModules.forEach(module => { - it(`returns true for ${module}`, () => { + test(`returns true for ${module}`, () => { expect(isReactModuleName(module)).toBe(true); }); }); - it(`returns false by default`, () => { + test(`returns false by default`, () => { expect(isReactModuleName('not-react')).toBe(false); }); }); diff --git a/packages/react-docgen/src/utils/__tests__/isRequiredPropType-test.ts b/packages/react-docgen/src/utils/__tests__/isRequiredPropType-test.ts index bc305584ffd..8f7d4266d1b 100644 --- a/packages/react-docgen/src/utils/__tests__/isRequiredPropType-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isRequiredPropType-test.ts @@ -1,8 +1,9 @@ import { parse } from '../../../tests/utils'; -import isRequiredPropType from '../isRequiredPropType'; +import isRequiredPropType from '../isRequiredPropType.js'; +import { describe, expect, test } from 'vitest'; describe('isRequiredPropType', () => { - it('considers isRequired', () => { + test('considers isRequired', () => { expect(isRequiredPropType(parse.expression('foo.bar.isRequired'))).toEqual( true, ); @@ -11,7 +12,7 @@ describe('isRequiredPropType', () => { ); }); - it('considers ["isRequired"]', () => { + test('considers ["isRequired"]', () => { expect( isRequiredPropType(parse.expression('foo.bar["isRequired"]')), ).toEqual(true); @@ -20,7 +21,7 @@ describe('isRequiredPropType', () => { ).toEqual(true); }); - it('ignores variables', () => { + test('ignores variables', () => { expect(isRequiredPropType(parse.expression('foo.bar[isRequired]'))).toEqual( false, ); diff --git a/packages/react-docgen/src/utils/__tests__/isStatelessComponent-test.ts b/packages/react-docgen/src/utils/__tests__/isStatelessComponent-test.ts index 7c7981a86ee..b40e8e20346 100644 --- a/packages/react-docgen/src/utils/__tests__/isStatelessComponent-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isStatelessComponent-test.ts @@ -1,8 +1,9 @@ import { parse } from '../../../tests/utils'; -import isStatelessComponent from '../isStatelessComponent'; +import isStatelessComponent from '../isStatelessComponent.js'; +import { describe, expect, test } from 'vitest'; describe('isStatelessComponent', () => { - it('accepts jsx', () => { + test('accepts jsx', () => { const def = parse(` var React = require('react'); var Foo = () =>
; @@ -14,7 +15,7 @@ describe('isStatelessComponent', () => { expect(isStatelessComponent(def)).toBe(true); }); - it('accepts jsx fragment', () => { + test('accepts jsx fragment', () => { const def = parse(` var React = require('react'); var Foo = () => <>; @@ -26,7 +27,7 @@ describe('isStatelessComponent', () => { expect(isStatelessComponent(def)).toBe(true); }); - it('accepts createElement', () => { + test('accepts createElement', () => { const def = parse(` var React = require('react'); var Foo = () => React.createElement("div", null); @@ -38,7 +39,7 @@ describe('isStatelessComponent', () => { expect(isStatelessComponent(def)).toBe(true); }); - it('accepts cloneElement', () => { + test('accepts cloneElement', () => { const def = parse(` var React = require('react'); var Foo = () => React.cloneElement("div", null); @@ -50,7 +51,7 @@ describe('isStatelessComponent', () => { expect(isStatelessComponent(def)).toBe(true); }); - it('accepts React.Children.only', () => { + test('accepts React.Children.only', () => { const def = parse(` var React = require('react'); var Foo = () => React.Children.only(children); @@ -62,7 +63,7 @@ describe('isStatelessComponent', () => { expect(isStatelessComponent(def)).toBe(true); }); - it('accepts React.Children.map', () => { + test('accepts React.Children.map', () => { const def = parse(` var React = require('react'); var Foo = () => React.Children.map(children, child => child); @@ -74,7 +75,7 @@ describe('isStatelessComponent', () => { expect(isStatelessComponent(def)).toBe(true); }); - it('accepts different name than React', () => { + test('accepts different name than React', () => { const def = parse(` var AlphaBetters = require('react'); var Foo = () => AlphaBetters.createElement("div", null); @@ -86,7 +87,7 @@ describe('isStatelessComponent', () => { expect(isStatelessComponent(def)).toBe(true); }); - it('Stateless Function Components inside module pattern', () => { + test('Stateless Function Components inside module pattern', () => { const def = parse(` var React = require('react'); var Foo = { @@ -115,7 +116,7 @@ describe('isStatelessComponent', () => { }); describe('is not overzealous', () => { - it('does not accept declarations with a render method', () => { + test('does not accept declarations with a render method', () => { const def = parse.statement(` class Foo { render() { @@ -127,7 +128,7 @@ describe('isStatelessComponent', () => { expect(isStatelessComponent(def)).toBe(false); }); - it('does not accept React.Component classes', () => { + test('does not accept React.Component classes', () => { const def = parse(` var React = require('react'); class Foo extends React.Component { @@ -140,7 +141,7 @@ describe('isStatelessComponent', () => { expect(isStatelessComponent(def)).toBe(false); }); - it('does not accept React.createClass calls', () => { + test('does not accept React.createClass calls', () => { const def = parse.statement(` React.createClass({ render() { diff --git a/packages/react-docgen/src/utils/__tests__/isUnreachableFlowType-test.ts b/packages/react-docgen/src/utils/__tests__/isUnreachableFlowType-test.ts index 012c5f226b4..b37fda1f274 100644 --- a/packages/react-docgen/src/utils/__tests__/isUnreachableFlowType-test.ts +++ b/packages/react-docgen/src/utils/__tests__/isUnreachableFlowType-test.ts @@ -1,22 +1,23 @@ import { parse } from '../../../tests/utils'; -import isUnreachableFlowType from '../isUnreachableFlowType'; +import isUnreachableFlowType from '../isUnreachableFlowType.js'; +import { describe, expect, test } from 'vitest'; describe('isUnreachableFlowType', () => { - it('considers Identifier as unreachable', () => { + test('considers Identifier as unreachable', () => { expect(isUnreachableFlowType(parse.expression('foo'))).toBe(true); }); - it('considers ImportDeclaration as unreachable', () => { + test('considers ImportDeclaration as unreachable', () => { expect(isUnreachableFlowType(parse.statement('import x from "";'))).toBe( true, ); }); - it('considers CallExpression as unreachable', () => { + test('considers CallExpression as unreachable', () => { expect(isUnreachableFlowType(parse.expression('foo()'))).toBe(true); }); - it('considers VariableDeclaration not as unreachable', () => { + test('considers VariableDeclaration not as unreachable', () => { expect(isUnreachableFlowType(parse.statement('const x = 1;'))).toBe(false); }); }); diff --git a/packages/react-docgen/src/utils/__tests__/match-test.ts b/packages/react-docgen/src/utils/__tests__/match-test.ts index 6c3fd1fcde2..c1e95bcefa7 100644 --- a/packages/react-docgen/src/utils/__tests__/match-test.ts +++ b/packages/react-docgen/src/utils/__tests__/match-test.ts @@ -1,5 +1,6 @@ import type { Node } from '@babel/types'; -import match from '../match'; +import match from '../match.js'; +import { describe, expect, test } from 'vitest'; describe('match', () => { const toASTNode = (obj: Record): Node => { @@ -7,19 +8,19 @@ describe('match', () => { return obj as any; }; - it('matches with exact properties', () => { + test('matches with exact properties', () => { expect(match(toASTNode({ foo: { bar: 42 } }), { foo: { bar: 42 } })).toBe( true, ); }); - it('matches a subset of properties in the target', () => { + test('matches a subset of properties in the target', () => { expect( match(toASTNode({ foo: { bar: 42, baz: 'xyz' } }), { foo: { bar: 42 } }), ).toBe(true); }); - it('does not match if properties are different/missing', () => { + test('does not match if properties are different/missing', () => { expect( match(toASTNode({ foo: { bar: 42, baz: 'xyz' } }), { foo: { bar: 21, baz: 'xyz' }, diff --git a/packages/react-docgen/src/utils/__tests__/normalizeClassDefinition-test.ts b/packages/react-docgen/src/utils/__tests__/normalizeClassDefinition-test.ts index 19a315845a3..a5ee2abdce7 100644 --- a/packages/react-docgen/src/utils/__tests__/normalizeClassDefinition-test.ts +++ b/packages/react-docgen/src/utils/__tests__/normalizeClassDefinition-test.ts @@ -11,10 +11,11 @@ import type { VariableDeclaration, } from '@babel/types'; import { parse } from '../../../tests/utils'; -import normalizeClassDefinition from '../normalizeClassDefinition'; +import normalizeClassDefinition from '../normalizeClassDefinition.js'; +import { describe, expect, test } from 'vitest'; describe('normalizeClassDefinition', () => { - it('finds assignments to class declarations', () => { + test('finds assignments to class declarations', () => { const classDefinition = parse.statement(` class Foo {} Foo.propTypes = 42; @@ -29,7 +30,7 @@ describe('normalizeClassDefinition', () => { expect(classProperty.static).toBe(true); }); - it('should not fail on classes without ids', () => { + test('should not fail on classes without ids', () => { const classDefinition = parse .statement( ` @@ -46,7 +47,7 @@ describe('normalizeClassDefinition', () => { expect(classProperty).toBeDefined(); }); - it('finds assignments to class expressions with variable declaration', () => { + test('finds assignments to class expressions with variable declaration', () => { const classDefinition = parse .statement( ` @@ -66,7 +67,7 @@ describe('normalizeClassDefinition', () => { expect(classProperty.static).toBe(true); }); - it('finds assignments to class expressions with assignment', () => { + test('finds assignments to class expressions with assignment', () => { const classDefinition = ( parse .statement( @@ -87,7 +88,7 @@ describe('normalizeClassDefinition', () => { expect(classProperty.static).toBe(true); }); - it('ignores assignments further up the tree', () => { + test('ignores assignments further up the tree', () => { const classDefinition = parse .statement( ` diff --git a/packages/react-docgen/src/utils/__tests__/parseJsDoc-test.ts b/packages/react-docgen/src/utils/__tests__/parseJsDoc-test.ts index f7449263ac2..947dcfb8744 100644 --- a/packages/react-docgen/src/utils/__tests__/parseJsDoc-test.ts +++ b/packages/react-docgen/src/utils/__tests__/parseJsDoc-test.ts @@ -1,8 +1,9 @@ -import parseJsDoc from '../parseJsDoc'; +import parseJsDoc from '../parseJsDoc.js'; +import { describe, expect, test } from 'vitest'; describe('parseJsDoc', () => { describe('description', () => { - it('extracts the method description in jsdoc', () => { + test('extracts the method description in jsdoc', () => { const docblock = ` Don't use this! `; @@ -22,7 +23,7 @@ describe('parseJsDoc', () => { Object.keys(docBlocks).forEach(name => { const docBlock = docBlocks[name]; - it(name, () => { + test(name, () => { expect(parseJsDoc(docBlock)).toMatchSnapshot(); }); }); @@ -39,7 +40,7 @@ describe('parseJsDoc', () => { Object.keys(docBlocks).forEach(name => { const docBlock = docBlocks[name]; - it(name, () => { + test(name, () => { expect(parseJsDoc(docBlock)).toMatchSnapshot(); }); }); diff --git a/packages/react-docgen/src/utils/__tests__/printValue-test.ts b/packages/react-docgen/src/utils/__tests__/printValue-test.ts index 29f40b580be..9b78639faca 100644 --- a/packages/react-docgen/src/utils/__tests__/printValue-test.ts +++ b/packages/react-docgen/src/utils/__tests__/printValue-test.ts @@ -1,22 +1,23 @@ import type { NodePath } from '@babel/traverse'; import type { ExpressionStatement, TSInterfaceDeclaration } from '@babel/types'; import { parse, parseTypescript } from '../../../tests/utils'; -import printValue from '../printValue'; +import printValue from '../printValue.js'; +import { describe, expect, test } from 'vitest'; describe('printValue', () => { function pathFromSource(source: string): NodePath { return parse.statement(source).get('expression'); } - it('does not print leading comments', () => { + test('does not print leading comments', () => { expect(printValue(pathFromSource('//foo\nbar'))).toEqual('bar'); }); - it('does not print trailing comments', () => { + test('does not print trailing comments', () => { expect(printValue(pathFromSource('bar//foo'))).toEqual('bar'); }); - it('deindents code', () => { + test('deindents code', () => { expect( printValue( pathFromSource(` ( function () { @@ -27,7 +28,7 @@ describe('printValue', () => { }); [',', ';'].forEach(char => { - it(`removes trailing ${char} for TsConstructSignatureDeclaration`, () => { + test(`removes trailing ${char} for TsConstructSignatureDeclaration`, () => { const path = parseTypescript .statement( `interface A { new (x:number)${char} }`, @@ -37,7 +38,7 @@ describe('printValue', () => { expect(printValue(path)).toMatchSnapshot(); }); - it(`removes trailing ${char} for TsIndexSignature`, () => { + test(`removes trailing ${char} for TsIndexSignature`, () => { const path = parseTypescript .statement( `interface A { [x:string]: number${char} }`, @@ -47,7 +48,7 @@ describe('printValue', () => { expect(printValue(path)).toMatchSnapshot(); }); - it(`removes trailing ${char} for TsCallSignatureDeclaration`, () => { + test(`removes trailing ${char} for TsCallSignatureDeclaration`, () => { const path = parseTypescript .statement(`interface A { (): number${char} }`) .get('body.body.0') as NodePath; @@ -55,7 +56,7 @@ describe('printValue', () => { expect(printValue(path)).toMatchSnapshot(); }); - it(`removes trailing ${char} for TsPropertySignature`, () => { + test(`removes trailing ${char} for TsPropertySignature`, () => { const path = parseTypescript .statement(`interface A { x: number${char} }`) .get('body.body.0') as NodePath; @@ -63,7 +64,7 @@ describe('printValue', () => { expect(printValue(path)).toMatchSnapshot(); }); - it(`removes trailing ${char} for TsMethodSignature`, () => { + test(`removes trailing ${char} for TsMethodSignature`, () => { const path = parseTypescript .statement(`interface A { x(): number${char} }`) .get('body.body.0') as NodePath; diff --git a/packages/react-docgen/src/utils/__tests__/resolveExportDeclaration-test.ts b/packages/react-docgen/src/utils/__tests__/resolveExportDeclaration-test.ts index 5136b41b51c..610ee98074b 100644 --- a/packages/react-docgen/src/utils/__tests__/resolveExportDeclaration-test.ts +++ b/packages/react-docgen/src/utils/__tests__/resolveExportDeclaration-test.ts @@ -4,21 +4,20 @@ import type { ExportNamedDeclaration, } from '@babel/types'; import { parse } from '../../../tests/utils'; -import resolveExportDeclaration from '../resolveExportDeclaration'; +import resolveExportDeclaration from '../resolveExportDeclaration.js'; +import { describe, expect, test, vi } from 'vitest'; -jest.mock('../resolveToValue', () => { - return (path: NodePath) => path; -}); +vi.mock('../resolveToValue.js', () => ({ default: (path: NodePath) => path })); describe('resolveExportDeclaration', () => { - it('resolves default exports', () => { + test('resolves default exports', () => { const exp = parse.statement('export default 42;'); const resolved = resolveExportDeclaration(exp); expect(resolved).toEqual([exp.get('declaration')]); }); - it('resolves named variable exports', () => { + test('resolves named variable exports', () => { const exp = parse.statement( 'export var foo = 42, bar = 21;', ); @@ -29,7 +28,7 @@ describe('resolveExportDeclaration', () => { expect(resolved).toEqual([declarations[0], declarations[1]]); }); - it('resolves named function exports', () => { + test('resolves named function exports', () => { const exp = parse.statement( 'export function foo(){}', ); @@ -38,14 +37,14 @@ describe('resolveExportDeclaration', () => { expect(resolved).toEqual([exp.get('declaration')]); }); - it('resolves named class exports', () => { + test('resolves named class exports', () => { const exp = parse.statement('export class Foo {}'); const resolved = resolveExportDeclaration(exp); expect(resolved).toEqual([exp.get('declaration')]); }); - it('resolves named exports', () => { + test('resolves named exports', () => { const exp = parse.statement( 'export {foo, bar, baz}; var foo, bar, baz;', ); @@ -60,7 +59,7 @@ describe('resolveExportDeclaration', () => { ]); }); - it('resolves named exports from', () => { + test('resolves named exports from', () => { const exp = parse.statement( 'export {foo, bar, baz} from "";', ); diff --git a/packages/react-docgen/src/utils/__tests__/resolveFunctionDefinitionToReturnValue-test.ts b/packages/react-docgen/src/utils/__tests__/resolveFunctionDefinitionToReturnValue-test.ts index 52a0e69adf8..42731c79fa6 100644 --- a/packages/react-docgen/src/utils/__tests__/resolveFunctionDefinitionToReturnValue-test.ts +++ b/packages/react-docgen/src/utils/__tests__/resolveFunctionDefinitionToReturnValue-test.ts @@ -1,9 +1,10 @@ import type { FunctionDeclaration } from '@babel/types'; import { parse } from '../../../tests/utils'; -import resolveFunctionDefinitionToReturnValue from '../resolveFunctionDefinitionToReturnValue'; +import resolveFunctionDefinitionToReturnValue from '../resolveFunctionDefinitionToReturnValue.js'; +import { describe, expect, test } from 'vitest'; describe('resolveFunctionDefinitionToReturnValue', () => { - it('can resolve easy return statement', () => { + test('can resolve easy return statement', () => { const path = parse.statement(` function x () { return "result"; } `); @@ -11,7 +12,7 @@ describe('resolveFunctionDefinitionToReturnValue', () => { expect(resolveFunctionDefinitionToReturnValue(path)).toMatchSnapshot(); }); - it('stops after first return', () => { + test('stops after first return', () => { const path = parse.statement(` function x () { return "first"; return "second"; } `); @@ -19,7 +20,7 @@ describe('resolveFunctionDefinitionToReturnValue', () => { expect(resolveFunctionDefinitionToReturnValue(path)).toMatchSnapshot(); }); - it('ignores return values in other blocks', () => { + test('ignores return values in other blocks', () => { const path = parse.statement(` function x () { const a = function () { return "funcexpr"; } diff --git a/packages/react-docgen/src/utils/__tests__/resolveGenericTypeAnnotations-test.ts b/packages/react-docgen/src/utils/__tests__/resolveGenericTypeAnnotations-test.ts index 75aab6b7941..4c6c45e8ebd 100644 --- a/packages/react-docgen/src/utils/__tests__/resolveGenericTypeAnnotations-test.ts +++ b/packages/react-docgen/src/utils/__tests__/resolveGenericTypeAnnotations-test.ts @@ -1,8 +1,9 @@ import { parse } from '../../../tests/utils'; -import resolveGenericTypeAnnotation from '../resolveGenericTypeAnnotation'; +import resolveGenericTypeAnnotation from '../resolveGenericTypeAnnotation.js'; +import { describe, expect, test } from 'vitest'; describe('resolveGenericTypeAnnotation', () => { - it('resolves type', () => { + test('resolves type', () => { const code = ` var x: Props; type Props = { x: string }; diff --git a/packages/react-docgen/src/utils/__tests__/resolveHOC-test.ts b/packages/react-docgen/src/utils/__tests__/resolveHOC-test.ts index 39f9405add2..1556d940d85 100644 --- a/packages/react-docgen/src/utils/__tests__/resolveHOC-test.ts +++ b/packages/react-docgen/src/utils/__tests__/resolveHOC-test.ts @@ -1,6 +1,7 @@ import { identifier, numericLiteral } from '@babel/types'; import { makeMockImporter, parse } from '../../../tests/utils'; -import resolveHOC from '../resolveHOC'; +import resolveHOC from '../resolveHOC.js'; +import { describe, expect, test } from 'vitest'; describe('resolveHOC', () => { const mockImporter = makeMockImporter({ @@ -16,31 +17,31 @@ describe('resolveHOC', () => { `).get('declaration'), }); - it('resolves simple hoc', () => { + test('resolves simple hoc', () => { const path = parse.expressionLast(['hoc(Component);'].join('\n')); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('resolves simple hoc w/ multiple args', () => { + test('resolves simple hoc w/ multiple args', () => { const path = parse.expressionLast( ['hoc1(arg1a, arg1b)(Component);'].join('\n'), ); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('resolves nested hocs', () => { + test('resolves nested hocs', () => { const path = parse.expressionLast( `hoc2(arg2b, arg2b)( hoc1(arg1a, arg2a)(Component) );`, ); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('resolves really nested hocs', () => { + test('resolves really nested hocs', () => { const path = parse.expressionLast( `hoc3(arg3a, arg3b)( hoc2(arg2b, arg2b)( @@ -49,48 +50,48 @@ describe('resolveHOC', () => { );`, ); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('resolves HOC with additional params', () => { + test('resolves HOC with additional params', () => { const path = parse.expressionLast(`hoc3(Component, {})`); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('resolves HOC as last element if first is literal', () => { + test('resolves HOC as last element if first is literal', () => { const path = parse.expressionLast(`hoc3(41, Component)`); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('resolves HOC as last element if first is array', () => { + test('resolves HOC as last element if first is array', () => { const path = parse.expressionLast(`hoc3([], Component)`); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('resolves HOC as last element if first is object', () => { + test('resolves HOC as last element if first is object', () => { const path = parse.expressionLast(`hoc3({}, Component)`); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('resolves HOC as last element if first is spread', () => { + test('resolves HOC as last element if first is spread', () => { const path = parse.expressionLast(`hoc3(...params, Component)`); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('resolves intermediate hocs', () => { + test('resolves intermediate hocs', () => { const path = parse.expressionLast( ['const Component = React.memo(42);', 'hoc()(Component);'].join('\n'), ); - expect(resolveHOC(path)).toEqualASTNode(numericLiteral(42)); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('can resolve an imported component passed to hoc', () => { + test('can resolve an imported component passed to hoc', () => { const path = parse.expressionLast( ` import foo from 'component'; @@ -99,10 +100,10 @@ describe('resolveHOC', () => { mockImporter, ); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('can resolve an imported component passed to nested hoc', () => { + test('can resolve an imported component passed to nested hoc', () => { const path = parse.expressionLast( ` import foo from 'component'; @@ -113,16 +114,16 @@ describe('resolveHOC', () => { mockImporter, ); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); - it('can resolve an hocs inside imported component passed to hoc', () => { + test('can resolve an hocs inside imported component passed to hoc', () => { const path = parse.expressionLast( `import bar from 'hoc'; hoc(bar);`, mockImporter, ); - expect(resolveHOC(path)).toEqualASTNode(identifier('Component')); + expect(resolveHOC(path)).toMatchSnapshot(); }); }); diff --git a/packages/react-docgen/src/utils/__tests__/resolveObjectKeysToArray-test.ts b/packages/react-docgen/src/utils/__tests__/resolveObjectKeysToArray-test.ts index 5121bbdae82..a2c7766f89f 100644 --- a/packages/react-docgen/src/utils/__tests__/resolveObjectKeysToArray-test.ts +++ b/packages/react-docgen/src/utils/__tests__/resolveObjectKeysToArray-test.ts @@ -1,5 +1,6 @@ import { makeMockImporter, parse } from '../../../tests/utils'; -import resolveObjectKeysToArray from '../resolveObjectKeysToArray'; +import resolveObjectKeysToArray from '../resolveObjectKeysToArray.js'; +import { describe, expect, test } from 'vitest'; describe('resolveObjectKeysToArray', () => { const mockImporter = makeMockImporter({ @@ -23,7 +24,7 @@ describe('resolveObjectKeysToArray', () => { `).get('declaration'), }); - it('resolves Object.keys with identifiers', () => { + test('resolves Object.keys with identifiers', () => { const path = parse.expressionLast( ['var foo = { bar: 1, foo: 2 };', 'Object.keys(foo);'].join('\n'), ); @@ -31,7 +32,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toMatchSnapshot(); }); - it('resolves Object.keys with literals', () => { + test('resolves Object.keys with literals', () => { const path = parse.expressionLast( ['var foo = { "bar": 1, 5: 2 };', 'Object.keys(foo);'].join('\n'), ); @@ -39,7 +40,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toMatchSnapshot(); }); - it('resolves Object.keys with literals as computed key', () => { + test('resolves Object.keys with literals as computed key', () => { const path = parse.expressionLast( ['var foo = { ["bar"]: 1, [5]: 2};', 'Object.keys(foo);'].join('\n'), ); @@ -47,7 +48,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toMatchSnapshot(); }); - it('resolves Object.keys when using resolvable spread', () => { + test('resolves Object.keys when using resolvable spread', () => { const path = parse.expressionLast( [ 'var bar = { doo: 4 }', @@ -59,7 +60,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toMatchSnapshot(); }); - it('resolves Object.keys when using getters', () => { + test('resolves Object.keys when using getters', () => { const path = parse.expressionLast( ['var foo = { boo: 1, foo: 2, get bar() {} };', 'Object.keys(foo);'].join( '\n', @@ -69,7 +70,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toMatchSnapshot(); }); - it('resolves Object.keys when using setters', () => { + test('resolves Object.keys when using setters', () => { const path = parse.expressionLast( [ 'var foo = { boo: 1, foo: 2, set bar(e) {} };', @@ -80,7 +81,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toMatchSnapshot(); }); - it('resolves Object.keys but ignores duplicates', () => { + test('resolves Object.keys but ignores duplicates', () => { const path = parse.expressionLast( [ 'var bar = { doo: 4, doo: 5 }', @@ -92,7 +93,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toMatchSnapshot(); }); - it('resolves Object.keys but ignores duplicates with getter and setter', () => { + test('resolves Object.keys but ignores duplicates with getter and setter', () => { const path = parse.expressionLast( ['var foo = { get x() {}, set x(a) {} };', 'Object.keys(foo);'].join( '\n', @@ -102,7 +103,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toMatchSnapshot(); }); - it('does not resolve Object.keys when using unresolvable spread', () => { + test('does not resolve Object.keys when using unresolvable spread', () => { const path = parse.expressionLast( ['var foo = { bar: 1, foo: 2, ...bar };', 'Object.keys(foo);'].join('\n'), ); @@ -110,7 +111,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toBeNull(); }); - it('does not resolve Object.keys when using computed keys', () => { + test('does not resolve Object.keys when using computed keys', () => { const path = parse.expressionLast( ['var foo = { [bar]: 1, foo: 2 };', 'Object.keys(foo);'].join('\n'), ); @@ -118,7 +119,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toBeNull(); }); - it('can resolve imported objects passed to Object.keys', () => { + test('can resolve imported objects passed to Object.keys', () => { const path = parse.expressionLast( `import foo from 'foo'; Object.keys(foo);`, @@ -128,7 +129,7 @@ describe('resolveObjectKeysToArray', () => { expect(resolveObjectKeysToArray(path)).toMatchSnapshot(); }); - it('can resolve spreads from imported objects', () => { + test('can resolve spreads from imported objects', () => { const path = parse.expressionLast( `import bar from 'bar'; var abc = { foo: 'foo', baz: 'baz', ...bar }; diff --git a/packages/react-docgen/src/utils/__tests__/resolveObjectPatternPropertyToValue-test.ts b/packages/react-docgen/src/utils/__tests__/resolveObjectPatternPropertyToValue-test.ts index 7a9e88ab980..4db175b66c9 100644 --- a/packages/react-docgen/src/utils/__tests__/resolveObjectPatternPropertyToValue-test.ts +++ b/packages/react-docgen/src/utils/__tests__/resolveObjectPatternPropertyToValue-test.ts @@ -6,10 +6,11 @@ import type { VariableDeclaration, } from '@babel/types'; import { parse } from '../../../tests/utils'; -import resolveObjectPatternPropertyToValue from '../resolveObjectPatternPropertyToValue'; +import resolveObjectPatternPropertyToValue from '../resolveObjectPatternPropertyToValue.js'; +import { describe, expect, test } from 'vitest'; describe('resolveObjectPatternPropertyToValue', () => { - it('does not resolve if not in ObjectProperty', () => { + test('does not resolve if not in ObjectProperty', () => { const path = parse .expressionLast( `const x = { a : "string" }; @@ -20,7 +21,7 @@ describe('resolveObjectPatternPropertyToValue', () => { expect(resolveObjectPatternPropertyToValue(path)).toBeNull(); }); - it('does not resolve if not in VariableDeclarator or AssignmentExpression', () => { + test('does not resolve if not in VariableDeclarator or AssignmentExpression', () => { const path = parse .expression(`({ a }) => {}`) .get('params.0.properties.0') as NodePath; @@ -29,7 +30,7 @@ describe('resolveObjectPatternPropertyToValue', () => { }); describe('VariableDeclarator', () => { - it('resolved basic case', () => { + test('resolved basic case', () => { const path = parse .statementLast( `const x = { a : "string" }; @@ -40,7 +41,7 @@ describe('resolveObjectPatternPropertyToValue', () => { expect(resolveObjectPatternPropertyToValue(path)).toMatchSnapshot(); }); - it('does not resolve if property not found', () => { + test('does not resolve if property not found', () => { const path = parse .statementLast( `const x = { b : "string" }; @@ -51,7 +52,7 @@ describe('resolveObjectPatternPropertyToValue', () => { expect(resolveObjectPatternPropertyToValue(path)).toBeNull(); }); - it('does not resolve when init not resolvable', () => { + test('does not resolve when init not resolvable', () => { const path = parse .statementLast(`const { a } = x;`) .get('declarations.0.id.properties.0') as NodePath; @@ -60,7 +61,7 @@ describe('resolveObjectPatternPropertyToValue', () => { }); }); describe('AssignmentExpression', () => { - it('resolved basic case', () => { + test('resolved basic case', () => { const path = parse .expressionLast( `const x = { a : "string" }; @@ -71,7 +72,7 @@ describe('resolveObjectPatternPropertyToValue', () => { expect(resolveObjectPatternPropertyToValue(path)).toMatchSnapshot(); }); - it('does not resolve if property not found', () => { + test('does not resolve if property not found', () => { const path = parse .expressionLast( `const x = { b : "string" }; @@ -82,7 +83,7 @@ describe('resolveObjectPatternPropertyToValue', () => { expect(resolveObjectPatternPropertyToValue(path)).toBeNull(); }); - it('does not resolve when init not resolvable', () => { + test('does not resolve when init not resolvable', () => { const path = parse .expression(`{ a } = x`) .get('left.properties.0') as NodePath; diff --git a/packages/react-docgen/src/utils/__tests__/resolveObjectValuesToArray-test.ts b/packages/react-docgen/src/utils/__tests__/resolveObjectValuesToArray-test.ts index db8f9d0764a..a9e2a6a5355 100644 --- a/packages/react-docgen/src/utils/__tests__/resolveObjectValuesToArray-test.ts +++ b/packages/react-docgen/src/utils/__tests__/resolveObjectValuesToArray-test.ts @@ -1,5 +1,6 @@ import { makeMockImporter, parse } from '../../../tests/utils'; -import resolveObjectValuesToArray from '../resolveObjectValuesToArray'; +import resolveObjectValuesToArray from '../resolveObjectValuesToArray.js'; +import { describe, expect, test } from 'vitest'; describe('resolveObjectValuesToArray', () => { const mockImporter = makeMockImporter({ @@ -25,7 +26,7 @@ describe('resolveObjectValuesToArray', () => { `).get('declaration'), }); - it('resolves Object.values with strings', () => { + test('resolves Object.values with strings', () => { const path = parse.expressionLast( ['var foo = { 1: "bar", 2: "foo" };', 'Object.values(foo);'].join('\n'), ); @@ -33,7 +34,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('resolves Object.values with numbers', () => { + test('resolves Object.values with numbers', () => { const path = parse.expressionLast( ['var foo = { 1: 0, 2: 5 };', 'Object.values(foo);'].join('\n'), ); @@ -41,7 +42,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('resolves Object.values with undefined or null', () => { + test('resolves Object.values with undefined or null', () => { const path = parse.expressionLast( ['var foo = { 1: null, 2: undefined };', 'Object.values(foo);'].join( '\n', @@ -51,7 +52,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('resolves Object.values with literals as computed key', () => { + test('resolves Object.values with literals as computed key', () => { const path = parse.expressionLast( ['var foo = { ["bar"]: 1, [5]: 2};', 'Object.values(foo);'].join('\n'), ); @@ -59,7 +60,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('does not resolve Object.values with complex computed key', () => { + test('does not resolve Object.values with complex computed key', () => { const path = parse.expressionLast( ['var foo = { [()=>{}]: 1, [5]: 2};', 'Object.values(foo);'].join('\n'), ); @@ -67,7 +68,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toBeNull(); }); - it('resolves Object.values when using resolvable spread', () => { + test('resolves Object.values when using resolvable spread', () => { const path = parse.expressionLast( [ 'var bar = { doo: 4 }', @@ -79,7 +80,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('resolves Object.values when using getters', () => { + test('resolves Object.values when using getters', () => { const path = parse.expressionLast( [ 'var foo = { boo: 1, foo: 2, get bar() {} };', @@ -90,7 +91,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('resolves Object.values when using setters', () => { + test('resolves Object.values when using setters', () => { const path = parse.expressionLast( [ 'var foo = { boo: 1, foo: 2, set bar(e) {} };', @@ -101,7 +102,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('resolves Object.values when using methods', () => { + test('resolves Object.values when using methods', () => { const path = parse.expressionLast( ['var foo = { boo: 1, foo: 2, bar(e) {} };', 'Object.values(foo);'].join( '\n', @@ -111,7 +112,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('resolves Object.values but ignores duplicates', () => { + test('resolves Object.values but ignores duplicates', () => { const path = parse.expressionLast( [ 'var bar = { doo: 4, doo: 5 }', @@ -123,7 +124,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('resolves Object.values but ignores duplicates with getter and setter', () => { + test('resolves Object.values but ignores duplicates with getter and setter', () => { const path = parse.expressionLast( ['var foo = { get x() {}, set x(a) {} };', 'Object.values(foo);'].join( '\n', @@ -133,7 +134,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('does not resolve Object.values when using unresolvable spread', () => { + test('does not resolve Object.values when using unresolvable spread', () => { const path = parse.expressionLast( ['var foo = { bar: 1, foo: 2, ...bar };', 'Object.values(foo);'].join( '\n', @@ -143,7 +144,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toBeNull(); }); - it('can resolve imported objects passed to Object.values', () => { + test('can resolve imported objects passed to Object.values', () => { const path = parse.expressionLast( `import foo from 'foo'; Object.values(foo);`, @@ -153,7 +154,7 @@ describe('resolveObjectValuesToArray', () => { expect(resolveObjectValuesToArray(path)).toMatchSnapshot(); }); - it('can resolve spreads from imported objects', () => { + test('can resolve spreads from imported objects', () => { const path = parse.expressionLast( `import bar from 'bar'; var abc = { foo: 'foo', baz: 'baz', ...bar }; diff --git a/packages/react-docgen/src/utils/__tests__/resolveToModule-test.ts b/packages/react-docgen/src/utils/__tests__/resolveToModule-test.ts index fd1e10421e3..60cd9751cca 100644 --- a/packages/react-docgen/src/utils/__tests__/resolveToModule-test.ts +++ b/packages/react-docgen/src/utils/__tests__/resolveToModule-test.ts @@ -1,5 +1,6 @@ import { parse, makeMockImporter } from '../../../tests/utils'; -import resolveToModule from '../resolveToModule'; +import resolveToModule from '../resolveToModule.js'; +import { describe, expect, test } from 'vitest'; describe('resolveToModule', () => { const mockImporter = makeMockImporter({ @@ -16,7 +17,7 @@ describe('resolveToModule', () => { `).get('declaration'), }); - it('resolves identifiers', () => { + test('resolves identifiers', () => { const path = parse.expressionLast(` var foo = require("Foo"); foo; @@ -25,7 +26,7 @@ describe('resolveToModule', () => { expect(resolveToModule(path)).toBe('Foo'); }); - it('resolves function calls', () => { + test('resolves function calls', () => { const path = parse.expressionLast(` var foo = require("Foo"); foo(); @@ -34,7 +35,7 @@ describe('resolveToModule', () => { expect(resolveToModule(path)).toBe('Foo'); }); - it('resolves member expressions', () => { + test('resolves member expressions', () => { const path = parse.expressionLast(` var foo = require("Foo"); foo.bar().baz; @@ -43,7 +44,7 @@ describe('resolveToModule', () => { expect(resolveToModule(path)).toBe('Foo'); }); - it('understands destructuring', () => { + test('understands destructuring', () => { const path = parse.expressionLast(` var {foo} = require("Foo"); foo; @@ -53,7 +54,7 @@ describe('resolveToModule', () => { }); describe('ES6 import declarations', () => { - it('resolves ImportDefaultSpecifier', () => { + test('resolves ImportDefaultSpecifier', () => { let path = parse.expressionLast(` import foo from "Foo"; foo; @@ -68,7 +69,7 @@ describe('resolveToModule', () => { expect(resolveToModule(path)).toBe('Foo'); }); - it('resolves ImportSpecifier', () => { + test('resolves ImportSpecifier', () => { const path = parse.expressionLast(` import {foo, bar} from "Foo"; bar; @@ -77,7 +78,7 @@ describe('resolveToModule', () => { expect(resolveToModule(path)).toBe('Foo'); }); - it('resolves aliased ImportSpecifier', () => { + test('resolves aliased ImportSpecifier', () => { const path = parse.expressionLast(` import {foo, bar as baz} from "Foo"; baz; @@ -86,7 +87,7 @@ describe('resolveToModule', () => { expect(resolveToModule(path)).toBe('Foo'); }); - it('resolves ImportNamespaceSpecifier', () => { + test('resolves ImportNamespaceSpecifier', () => { const path = parse.expressionLast(` import * as foo from "Foo"; foo; @@ -95,7 +96,7 @@ describe('resolveToModule', () => { expect(resolveToModule(path)).toBe('Foo'); }); - it('can resolve imports until one not expanded', () => { + test('can resolve imports until one not expanded', () => { const path = parse.expressionLast( ` import foo from "Foo"; diff --git a/packages/react-docgen/src/utils/__tests__/resolveToValue-test.ts b/packages/react-docgen/src/utils/__tests__/resolveToValue-test.ts index fe0040db1f4..2e35ea5356c 100644 --- a/packages/react-docgen/src/utils/__tests__/resolveToValue-test.ts +++ b/packages/react-docgen/src/utils/__tests__/resolveToValue-test.ts @@ -1,11 +1,4 @@ import type { NodePath } from '@babel/traverse'; -import { - identifier, - memberExpression, - numericLiteral, - objectProperty, - restElement, -} from '@babel/types'; import type { AssignmentExpression, CallExpression, @@ -13,7 +6,8 @@ import type { ExportNamedDeclaration, } from '@babel/types'; import { makeMockImporter, parse, parseTypescript } from '../../../tests/utils'; -import resolveToValue from '../resolveToValue'; +import resolveToValue from '../resolveToValue.js'; +import { describe, expect, test } from 'vitest'; describe('resolveToValue', () => { const mockImporter = makeMockImporter({ @@ -26,55 +20,43 @@ describe('resolveToValue', () => { .get('local') as NodePath, }); - it('resolves simple variable declarations', () => { + test('resolves simple variable declarations', () => { const path = parse.expressionLast(['var foo = 42;', 'foo;'].join('\n')); - expect(resolveToValue(path)).toEqualASTNode(numericLiteral(42)); + expect(resolveToValue(path)).toMatchSnapshot(); }); - it('resolves object destructuring', () => { + test('resolves object destructuring', () => { const path = parse.expressionLast( ['var {foo: {bar: baz}} = bar;', 'baz;'].join('\n'), ); - const expected = objectProperty( - identifier('bar'), - identifier('baz'), - undefined, - undefined, - undefined, - ); - - expected.decorators = undefined; - // @ts-ignore BABEL types bug - expected.method = false; - // Resolves to identifier in destructuring - expect(resolveToValue(path)).toEqualASTNode(expected); + expect(resolveToValue(path)).toMatchSnapshot(); }); - it('handles RestElements properly', () => { + test('handles RestElements properly', () => { const path = parse.expressionLast( ['var {foo: {bar}, ...baz} = bar;', 'baz;'].join('\n'), ); - expect(resolveToValue(path)).toEqualASTNode(restElement(identifier('baz'))); + expect(resolveToValue(path)).toMatchSnapshot(); }); - it('returns the original path if it cannot be resolved', () => { + test('returns the original path if it cannot be resolved', () => { const path = parse.expressionLast( ['function foo() {}', 'foo()'].join('\n'), ); - expect(resolveToValue(path)).toEqualASTNode(path); + expect(resolveToValue(path)).toBe(path); }); - it('resolves variable declarators to their init value', () => { + test('resolves variable declarators to their init value', () => { const path = parse.statement('var foo = 42;').get('declarations')[0]; - expect(resolveToValue(path)).toEqualASTNode(numericLiteral(42)); + expect(resolveToValue(path)).toMatchSnapshot(); }); - it('resolves to class declarations', () => { + test('resolves to class declarations', () => { const path = parse.expressionLast(` class Foo {} Foo; @@ -83,7 +65,7 @@ describe('resolveToValue', () => { expect(resolveToValue(path).node.type).toBe('ClassDeclaration'); }); - it('resolves to class function declaration', () => { + test('resolves to class function declaration', () => { const path = parse.expressionLast(` function foo() {} foo; @@ -93,7 +75,7 @@ describe('resolveToValue', () => { }); describe('flow', () => { - it('resolves type cast expressions', () => { + test('resolves type cast expressions', () => { const path = parse.expressionLast(` function foo() {} (foo: any); @@ -104,7 +86,7 @@ describe('resolveToValue', () => { }); describe('typescript', () => { - it('resolves type as expressions', () => { + test('resolves type as expressions', () => { const path = parseTypescript.expressionLast(` function foo() {} (foo as any); @@ -113,7 +95,7 @@ describe('resolveToValue', () => { expect(resolveToValue(path).node.type).toBe('FunctionDeclaration'); }); - it('resolves type assertions', () => { + test('resolves type assertions', () => { const path = parseTypescript.expressionLast(` function foo() {} ( foo); @@ -122,7 +104,7 @@ describe('resolveToValue', () => { expect(resolveToValue(path).node.type).toBe('FunctionDeclaration'); }); - it('resolves type alias', () => { + test('resolves type alias', () => { const path = parseTypescript.statement( `let action: Action; type Action = {};`, @@ -139,25 +121,23 @@ describe('resolveToValue', () => { }); describe('assignments', () => { - it('resolves to assigned values', () => { + test('resolves to assigned values', () => { const path = parse.expressionLast( ['var foo;', 'foo = 42;', 'foo;'].join('\n'), ); - expect(resolveToValue(path)).toEqualASTNode(numericLiteral(42)); + expect(resolveToValue(path)).toMatchSnapshot(); }); - it('resolves to other assigned value if ref is in an assignment lhs', () => { + test('resolves to other assigned value if ref is in an assignment lhs', () => { const path = parse.expressionLast( ['var foo;', 'foo = 42;', 'foo = wrap(foo);'].join('\n'), ); - expect(resolveToValue(path.get('left'))).toEqualASTNode( - numericLiteral(42), - ); + expect(resolveToValue(path.get('left'))).toMatchSnapshot(); }); - it('resolves to other assigned value if ref is in an assignment rhs', () => { + test('resolves to other assigned value if ref is in an assignment rhs', () => { const path = parse.expressionLast( ['var foo;', 'foo = 42;', 'foo = wrap(foo);'].join('\n'), ); @@ -166,12 +146,12 @@ describe('resolveToValue', () => { resolveToValue( (path.get('right') as NodePath).get('arguments')[0], ), - ).toEqualASTNode(numericLiteral(42)); + ).toMatchSnapshot(); }); }); describe('ImportDeclaration', () => { - it('resolves unresolvable default import references to the import declaration', () => { + test('resolves unresolvable default import references to the import declaration', () => { const path = parse.expressionLast( ['import foo from "Foo"', 'foo;'].join('\n'), ); @@ -180,7 +160,7 @@ describe('resolveToValue', () => { expect(value.node.type).toBe('ImportDeclaration'); }); - it('resolves unresolvable named import references to the import declaration', () => { + test('resolves unresolvable named import references to the import declaration', () => { const path = parse.expressionLast( ['import {foo} from "Foo"', 'foo;'].join('\n'), ); @@ -189,7 +169,7 @@ describe('resolveToValue', () => { expect(value.node.type).toBe('ImportDeclaration'); }); - it('resolves unresolvable aliased import references to the import declaration', () => { + test('resolves unresolvable aliased import references to the import declaration', () => { const path = parse.expressionLast( ['import {foo as bar} from "Foo"', 'bar;'].join('\n'), ); @@ -198,7 +178,7 @@ describe('resolveToValue', () => { expect(value.node.type).toBe('ImportDeclaration'); }); - it('resolves unresolvable namespace import references to the import declaration', () => { + test('resolves unresolvable namespace import references to the import declaration', () => { const path = parse.expressionLast( ['import * as bar from "Foo"', 'bar;'].join('\n'), ); @@ -207,7 +187,7 @@ describe('resolveToValue', () => { expect(value.node.type).toBe('ImportDeclaration'); }); - it('resolves namespace import references to the import declaration', () => { + test('resolves namespace import references to the import declaration', () => { const path = parse.expressionLast( `import * as bar from "Foo"; bar.baz`, mockImporter, @@ -217,7 +197,7 @@ describe('resolveToValue', () => { expect(value).toMatchSnapshot(); }); - it('resolves namespace import references to the import declaration', () => { + test('resolves namespace import references to the import declaration', () => { const path = parse.expressionLast( `import * as bar from "Foo"; bar['baz']`, mockImporter, @@ -227,7 +207,7 @@ describe('resolveToValue', () => { expect(value).toMatchSnapshot(); }); - it('does not crash when resolving MemberExpression with non Identifiers', () => { + test('does not crash when resolving MemberExpression with non Identifiers', () => { const path = parse.expressionLast( `import * as bar from "Foo"; bar[()=>{}]`, mockImporter, @@ -239,23 +219,23 @@ describe('resolveToValue', () => { }); describe('MemberExpression', () => { - it("resolves a MemberExpression to it's init value", () => { + test("resolves a MemberExpression to it's init value", () => { const path = parse.expressionLast( ['var foo = { bar: 1 };', 'foo.bar;'].join('\n'), ); - expect(resolveToValue(path)).toEqualASTNode(numericLiteral(1)); + expect(resolveToValue(path)).toMatchSnapshot(); }); - it('resolves a MemberExpression in the scope chain', () => { + test('resolves a MemberExpression in the scope chain', () => { const path = parse.expressionLast( ['var foo = 1;', 'var bar = { baz: foo };', 'bar.baz;'].join('\n'), ); - expect(resolveToValue(path)).toEqualASTNode(numericLiteral(1)); + expect(resolveToValue(path)).toMatchSnapshot(); }); - it('resolves a nested MemberExpression in the scope chain', () => { + test('resolves a nested MemberExpression in the scope chain', () => { const path = parse.expressionLast( [ 'var foo = { bar: 1 };', @@ -264,10 +244,10 @@ describe('resolveToValue', () => { ].join('\n'), ); - expect(resolveToValue(path)).toEqualASTNode(numericLiteral(1)); + expect(resolveToValue(path)).toMatchSnapshot(); }); - it('returns the last resolvable MemberExpression', () => { + test('returns the last resolvable MemberExpression', () => { const path = parse.expressionLast( [ 'import foo from "bar";', @@ -276,19 +256,17 @@ describe('resolveToValue', () => { ].join('\n'), ); - expect(resolveToValue(path)).toEqualASTNode( - memberExpression(identifier('foo'), identifier('bar'), false, false), - ); + expect(resolveToValue(path)).toMatchSnapshot(); }); - it('returns the path itself if it can not resolve it any further', () => { + test('returns the path itself if it can not resolve it any further', () => { const path = parse.expressionLast( `var foo = {}; foo.bar = 1; foo.bar;`, ); - expect(resolveToValue(path)).toEqualASTNode(path); + expect(resolveToValue(path)).toBe(path); }); }); }); diff --git a/packages/react-docgen/src/utils/__tests__/setPropDescription-test.ts b/packages/react-docgen/src/utils/__tests__/setPropDescription-test.ts index 60a334eb421..f7c4ad2ad24 100644 --- a/packages/react-docgen/src/utils/__tests__/setPropDescription-test.ts +++ b/packages/react-docgen/src/utils/__tests__/setPropDescription-test.ts @@ -1,10 +1,11 @@ import { parse, makeMockImporter } from '../../../tests/utils'; -import setPropDescription from '../setPropDescription'; +import setPropDescription from '../setPropDescription.js'; import Documentation from '../../Documentation'; import type { default as DocumentationMock } from '../../__mocks__/Documentation'; import type { ExpressionStatement } from '@babel/types'; +import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'; -jest.mock('../../Documentation'); +vi.mock('../../Documentation.js'); describe('setPropDescription', () => { let defaultDocumentation: Documentation & DocumentationMock; @@ -26,7 +27,7 @@ describe('setPropDescription', () => { return documentation.descriptors; } - it('detects comments', () => { + test('detects comments', () => { const descriptors = getDescriptors(`{ /** * my description 3 @@ -42,7 +43,7 @@ describe('setPropDescription', () => { }); }); - it('does not update description if already set', () => { + test('does not update description if already set', () => { defaultDocumentation.getPropDescriptor('foo').description = '12345678'; const descriptors = getDescriptors( @@ -60,7 +61,7 @@ describe('setPropDescription', () => { }); }); - it('sets an empty description if comment does not exist', () => { + test('sets an empty description if comment does not exist', () => { const descriptors = getDescriptors(`{ hal: boolean, }`); @@ -72,7 +73,7 @@ describe('setPropDescription', () => { }); }); - it('resolves computed props to imported values', () => { + test('resolves computed props to imported values', () => { const src = ` ({ /** diff --git a/packages/react-docgen/src/utils/expressionTo.ts b/packages/react-docgen/src/utils/expressionTo.ts index 55b2fe1b3e5..c460ec1f6ca 100644 --- a/packages/react-docgen/src/utils/expressionTo.ts +++ b/packages/react-docgen/src/utils/expressionTo.ts @@ -1,6 +1,6 @@ /*eslint no-loop-func: 0, no-use-before-define: 0*/ -import resolveToValue from './resolveToValue'; +import resolveToValue from './resolveToValue.js'; import type { Node, NodePath } from '@babel/traverse'; /** diff --git a/packages/react-docgen/src/utils/findFunctionReturn.ts b/packages/react-docgen/src/utils/findFunctionReturn.ts index 8718dac57bb..bee4c59d1e6 100644 --- a/packages/react-docgen/src/utils/findFunctionReturn.ts +++ b/packages/react-docgen/src/utils/findFunctionReturn.ts @@ -1,7 +1,7 @@ import type { NodePath } from '@babel/traverse'; import { visitors } from '@babel/traverse'; -import resolveToValue from './resolveToValue'; -import { ignore } from './traverse'; +import resolveToValue from './resolveToValue.js'; +import { ignore } from './traverse.js'; type Predicate = (p: NodePath) => boolean; interface TraverseState { diff --git a/packages/react-docgen/src/utils/getClassMemberValuePath.ts b/packages/react-docgen/src/utils/getClassMemberValuePath.ts index 9868fd888ca..4898d43b9b9 100644 --- a/packages/react-docgen/src/utils/getClassMemberValuePath.ts +++ b/packages/react-docgen/src/utils/getClassMemberValuePath.ts @@ -6,7 +6,7 @@ import type { ClassProperty, Expression, } from '@babel/types'; -import getNameOrValue from './getNameOrValue'; +import getNameOrValue from './getNameOrValue.js'; export default function getClassMemberValuePath( classDefinition: NodePath, diff --git a/packages/react-docgen/src/utils/getFlowType.ts b/packages/react-docgen/src/utils/getFlowType.ts index 95e552c13d0..36ea35a315b 100644 --- a/packages/react-docgen/src/utils/getFlowType.ts +++ b/packages/react-docgen/src/utils/getFlowType.ts @@ -1,17 +1,17 @@ -import getPropertyName from './getPropertyName'; -import printValue from './printValue'; -import getTypeAnnotation from '../utils/getTypeAnnotation'; -import resolveToValue from '../utils/resolveToValue'; -import { resolveObjectToNameArray } from '../utils/resolveObjectKeysToArray'; -import type { TypeParameters } from '../utils/getTypeParameters'; -import getTypeParameters from '../utils/getTypeParameters'; +import getPropertyName from './getPropertyName.js'; +import printValue from './printValue.js'; +import getTypeAnnotation from '../utils/getTypeAnnotation.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import { resolveObjectToNameArray } from '../utils/resolveObjectKeysToArray.js'; +import type { TypeParameters } from '../utils/getTypeParameters.js'; +import getTypeParameters from '../utils/getTypeParameters.js'; import type { ElementsType, FunctionSignatureType, ObjectSignatureType, SimpleType, TypeDescriptor, -} from '../Documentation'; +} from '../Documentation.js'; import type { NodePath } from '@babel/traverse'; import type { ArrayTypeAnnotation, diff --git a/packages/react-docgen/src/utils/getMemberExpressionValuePath.ts b/packages/react-docgen/src/utils/getMemberExpressionValuePath.ts index d47fcf04cd2..895601720e3 100644 --- a/packages/react-docgen/src/utils/getMemberExpressionValuePath.ts +++ b/packages/react-docgen/src/utils/getMemberExpressionValuePath.ts @@ -1,9 +1,9 @@ import type { NodePath } from '@babel/traverse'; import { visitors } from '@babel/traverse'; import type { Expression } from '@babel/types'; -import getNameOrValue from './getNameOrValue'; -import { String as toString } from './expressionTo'; -import isReactForwardRefCall from './isReactForwardRefCall'; +import getNameOrValue from './getNameOrValue.js'; +import { String as toString } from './expressionTo.js'; +import isReactForwardRefCall from './isReactForwardRefCall.js'; function resolveName(path: NodePath): string | undefined { if (path.isVariableDeclaration()) { diff --git a/packages/react-docgen/src/utils/getMemberValuePath.ts b/packages/react-docgen/src/utils/getMemberValuePath.ts index dbde4835bdb..d30af6c20bd 100644 --- a/packages/react-docgen/src/utils/getMemberValuePath.ts +++ b/packages/react-docgen/src/utils/getMemberValuePath.ts @@ -1,8 +1,8 @@ import type { NodePath } from '@babel/traverse'; -import getClassMemberValuePath from './getClassMemberValuePath'; -import getMemberExpressionValuePath from './getMemberExpressionValuePath'; -import getPropertyValuePath from './getPropertyValuePath'; -import resolveFunctionDefinitionToReturnValue from '../utils/resolveFunctionDefinitionToReturnValue'; +import getClassMemberValuePath from './getClassMemberValuePath.js'; +import getMemberExpressionValuePath from './getMemberExpressionValuePath.js'; +import getPropertyValuePath from './getPropertyValuePath.js'; +import resolveFunctionDefinitionToReturnValue from '../utils/resolveFunctionDefinitionToReturnValue.js'; import type { CallExpression, ClassDeclaration, @@ -14,7 +14,7 @@ import type { TaggedTemplateExpression, VariableDeclaration, } from '@babel/types'; -import type { StatelessComponentNode } from '../resolver'; +import type { StatelessComponentNode } from '../resolver/index.js'; type SupportedNodes = | CallExpression diff --git a/packages/react-docgen/src/utils/getMethodDocumentation.ts b/packages/react-docgen/src/utils/getMethodDocumentation.ts index 15850025a00..251baf526b1 100644 --- a/packages/react-docgen/src/utils/getMethodDocumentation.ts +++ b/packages/react-docgen/src/utils/getMethodDocumentation.ts @@ -10,21 +10,21 @@ import type { ObjectProperty, TSType, } from '@babel/types'; -import { getDocblock } from './docblock'; -import getFlowType from './getFlowType'; -import getTSType from './getTSType'; -import getParameterName from './getParameterName'; -import getPropertyName from './getPropertyName'; -import getTypeAnnotation from './getTypeAnnotation'; -import resolveToValue from './resolveToValue'; -import printValue from './printValue'; +import { getDocblock } from './docblock.js'; +import getFlowType from './getFlowType.js'; +import getTSType from './getTSType.js'; +import getParameterName from './getParameterName.js'; +import getPropertyName from './getPropertyName.js'; +import getTypeAnnotation from './getTypeAnnotation.js'; +import resolveToValue from './resolveToValue.js'; +import printValue from './printValue.js'; import type { MethodDescriptor, MethodModifier, MethodParameter, MethodReturn, TypeDescriptor, -} from '../Documentation'; +} from '../Documentation.js'; export type MethodNodePath = | NodePath diff --git a/packages/react-docgen/src/utils/getNameOrValue.ts b/packages/react-docgen/src/utils/getNameOrValue.ts index 0b8449047ec..c78c91ea178 100644 --- a/packages/react-docgen/src/utils/getNameOrValue.ts +++ b/packages/react-docgen/src/utils/getNameOrValue.ts @@ -1,5 +1,5 @@ import type { NodePath } from '@babel/traverse'; -import printValue from './printValue'; +import printValue from './printValue.js'; /** * If node is an Identifier, it returns its name. If it is a literal, it returns diff --git a/packages/react-docgen/src/utils/getParameterName.ts b/packages/react-docgen/src/utils/getParameterName.ts index e42434b4a42..1107cbfe2cd 100644 --- a/packages/react-docgen/src/utils/getParameterName.ts +++ b/packages/react-docgen/src/utils/getParameterName.ts @@ -7,7 +7,7 @@ import type { RestElement, TSParameterProperty, } from '@babel/types'; -import printValue from './printValue'; +import printValue from './printValue.js'; type ParameterNodePath = NodePath< | ArrayPattern diff --git a/packages/react-docgen/src/utils/getPropType.ts b/packages/react-docgen/src/utils/getPropType.ts index ffa8d26ad86..68c652a8f4b 100644 --- a/packages/react-docgen/src/utils/getPropType.ts +++ b/packages/react-docgen/src/utils/getPropType.ts @@ -1,14 +1,14 @@ /*eslint no-use-before-define: 0*/ import type { NodePath } from '@babel/traverse'; -import { getDocblock } from '../utils/docblock'; -import getMembers from './getMembers'; -import getPropertyName from './getPropertyName'; -import isRequiredPropType from '../utils/isRequiredPropType'; -import printValue from './printValue'; -import resolveToValue from './resolveToValue'; -import resolveObjectKeysToArray from './resolveObjectKeysToArray'; -import resolveObjectValuesToArray from './resolveObjectValuesToArray'; -import type { PropTypeDescriptor, PropDescriptor } from '../Documentation'; +import { getDocblock } from '../utils/docblock.js'; +import getMembers from './getMembers.js'; +import getPropertyName from './getPropertyName.js'; +import isRequiredPropType from '../utils/isRequiredPropType.js'; +import printValue from './printValue.js'; +import resolveToValue from './resolveToValue.js'; +import resolveObjectKeysToArray from './resolveObjectKeysToArray.js'; +import resolveObjectValuesToArray from './resolveObjectValuesToArray.js'; +import type { PropTypeDescriptor, PropDescriptor } from '../Documentation.js'; import type { ArrayExpression, Expression, diff --git a/packages/react-docgen/src/utils/getPropertyName.ts b/packages/react-docgen/src/utils/getPropertyName.ts index 796d307daca..72e27dc3144 100644 --- a/packages/react-docgen/src/utils/getPropertyName.ts +++ b/packages/react-docgen/src/utils/getPropertyName.ts @@ -11,8 +11,8 @@ import type { TSMethodSignature, TSPropertySignature, } from '@babel/types'; -import getNameOrValue from './getNameOrValue'; -import resolveToValue from './resolveToValue'; +import getNameOrValue from './getNameOrValue.js'; +import resolveToValue from './resolveToValue.js'; export const COMPUTED_PREFIX = '@computed#'; diff --git a/packages/react-docgen/src/utils/getPropertyValuePath.ts b/packages/react-docgen/src/utils/getPropertyValuePath.ts index ea5b2cea10c..742d4a863ff 100644 --- a/packages/react-docgen/src/utils/getPropertyValuePath.ts +++ b/packages/react-docgen/src/utils/getPropertyValuePath.ts @@ -1,6 +1,6 @@ import type { NodePath } from '@babel/traverse'; import type { Expression, ObjectExpression, ObjectMethod } from '@babel/types'; -import getPropertyName from './getPropertyName'; +import getPropertyName from './getPropertyName.js'; /** * Given an ObjectExpression, this function returns the path of the value of diff --git a/packages/react-docgen/src/utils/getTSType.ts b/packages/react-docgen/src/utils/getTSType.ts index 604687187e0..88b8bdf91f3 100644 --- a/packages/react-docgen/src/utils/getTSType.ts +++ b/packages/react-docgen/src/utils/getTSType.ts @@ -1,10 +1,10 @@ -import getPropertyName from './getPropertyName'; -import printValue from './printValue'; -import getTypeAnnotation from '../utils/getTypeAnnotation'; -import resolveToValue from '../utils/resolveToValue'; -import { resolveObjectToNameArray } from '../utils/resolveObjectKeysToArray'; -import type { TypeParameters } from '../utils/getTypeParameters'; -import getTypeParameters from '../utils/getTypeParameters'; +import getPropertyName from './getPropertyName.js'; +import printValue from './printValue.js'; +import getTypeAnnotation from '../utils/getTypeAnnotation.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import { resolveObjectToNameArray } from '../utils/resolveObjectKeysToArray.js'; +import type { TypeParameters } from '../utils/getTypeParameters.js'; +import getTypeParameters from '../utils/getTypeParameters.js'; import type { ElementsType, FunctionArgumentType, @@ -13,7 +13,7 @@ import type { SimpleType, TypeDescriptor, TSFunctionSignatureType, -} from '../Documentation'; +} from '../Documentation.js'; import type { NodePath } from '@babel/traverse'; import type { TSUnionType, @@ -36,7 +36,7 @@ import type { RestElement, TypeScript, } from '@babel/types'; -import { getDocblock } from './docblock'; +import { getDocblock } from './docblock.js'; const tsTypes = { TSAnyKeyword: 'any', diff --git a/packages/react-docgen/src/utils/getTypeFromReactComponent.ts b/packages/react-docgen/src/utils/getTypeFromReactComponent.ts index fc2f5d30a5f..9debc642bd7 100644 --- a/packages/react-docgen/src/utils/getTypeFromReactComponent.ts +++ b/packages/react-docgen/src/utils/getTypeFromReactComponent.ts @@ -1,13 +1,13 @@ import type { NodePath } from '@babel/traverse'; -import type Documentation from '../Documentation'; -import getMemberValuePath from './getMemberValuePath'; -import getTypeAnnotation from './getTypeAnnotation'; -import getTypeParameters from './getTypeParameters'; -import isReactComponentClass from './isReactComponentClass'; -import isReactForwardRefCall from './isReactForwardRefCall'; -import resolveGenericTypeAnnotation from './resolveGenericTypeAnnotation'; -import resolveToValue from './resolveToValue'; -import type { TypeParameters } from './getTypeParameters'; +import type Documentation from '../Documentation.js'; +import getMemberValuePath from './getMemberValuePath.js'; +import getTypeAnnotation from './getTypeAnnotation.js'; +import getTypeParameters from './getTypeParameters.js'; +import isReactComponentClass from './isReactComponentClass.js'; +import isReactForwardRefCall from './isReactForwardRefCall.js'; +import resolveGenericTypeAnnotation from './resolveGenericTypeAnnotation.js'; +import resolveToValue from './resolveToValue.js'; +import type { TypeParameters } from './getTypeParameters.js'; import type { FlowType, InterfaceDeclaration, @@ -20,7 +20,7 @@ import type { TypeParameterDeclaration, TypeParameterInstantiation, } from '@babel/types'; -import getTypeIdentifier from './getTypeIdentifier'; +import getTypeIdentifier from './getTypeIdentifier.js'; // TODO TESTME diff --git a/packages/react-docgen/src/utils/getTypeParameters.ts b/packages/react-docgen/src/utils/getTypeParameters.ts index 27e40a5cf28..9f0e9c4655d 100644 --- a/packages/react-docgen/src/utils/getTypeParameters.ts +++ b/packages/react-docgen/src/utils/getTypeParameters.ts @@ -1,4 +1,4 @@ -import resolveGenericTypeAnnotation from '../utils/resolveGenericTypeAnnotation'; +import resolveGenericTypeAnnotation from '../utils/resolveGenericTypeAnnotation.js'; import type { NodePath } from '@babel/traverse'; import type { FlowType, diff --git a/packages/react-docgen/src/utils/index.ts b/packages/react-docgen/src/utils/index.ts index f84339b8152..39aebec230c 100644 --- a/packages/react-docgen/src/utils/index.ts +++ b/packages/react-docgen/src/utils/index.ts @@ -1,64 +1,68 @@ -import * as docblock from './docblock'; -import * as expressionTo from './expressionTo'; -import * as flowUtilityTypes from './flowUtilityTypes'; -import * as traverse from './traverse'; +import * as docblock from './docblock.js'; +import * as expressionTo from './expressionTo.js'; +import * as flowUtilityTypes from './flowUtilityTypes.js'; +import * as traverse from './traverse.js'; export { docblock, expressionTo, flowUtilityTypes, traverse }; -export { default as getClassMemberValuePath } from './getClassMemberValuePath'; -export { default as getFlowType } from './getFlowType'; -export { default as getMemberExpressionRoot } from './getMemberExpressionRoot'; -export { default as getMemberExpressionValuePath } from './getMemberExpressionValuePath'; -export { default as getMembers } from './getMembers'; +export { default as findFunctionReturn } from './findFunctionReturn.js'; +export { default as getClassMemberValuePath } from './getClassMemberValuePath.js'; +export { default as getFlowType } from './getFlowType.js'; +export { default as getMemberExpressionRoot } from './getMemberExpressionRoot.js'; +export { default as getMemberExpressionValuePath } from './getMemberExpressionValuePath.js'; +export { default as getMembers } from './getMembers.js'; export { default as getMemberValuePath, isSupportedDefinitionType, -} from './getMemberValuePath'; -export { default as getMethodDocumentation } from './getMethodDocumentation'; -export type { MethodNodePath } from './getMethodDocumentation'; -export { default as getNameOrValue } from './getNameOrValue'; -export { default as getParameterName } from './getParameterName'; -export { default as getPropertyName, COMPUTED_PREFIX } from './getPropertyName'; -export { default as getPropertyValuePath } from './getPropertyValuePath'; -export { default as getPropType } from './getPropType'; -export { default as getTSType } from './getTSType'; -export { default as getTypeAnnotation } from './getTypeAnnotation'; +} from './getMemberValuePath.js'; +export { default as getMethodDocumentation } from './getMethodDocumentation.js'; +export type { MethodNodePath } from './getMethodDocumentation.js'; +export { default as getNameOrValue } from './getNameOrValue.js'; +export { default as getParameterName } from './getParameterName.js'; +export { + default as getPropertyName, + COMPUTED_PREFIX, +} from './getPropertyName.js'; +export { default as getPropertyValuePath } from './getPropertyValuePath.js'; +export { default as getPropType } from './getPropType.js'; +export { default as getTSType } from './getTSType.js'; +export { default as getTypeAnnotation } from './getTypeAnnotation.js'; export { default as getTypeFromReactComponent, applyToTypeProperties, -} from './getTypeFromReactComponent'; -export { default as getTypeIdentifier } from './getTypeIdentifier'; -export { default as getTypeParameters } from './getTypeParameters'; -export type { TypeParameters } from './getTypeParameters'; -export { default as isDestructuringAssignment } from './isDestructuringAssignment'; -export { default as isExportsOrModuleAssignment } from './isExportsOrModuleAssignment'; -export { default as isReactBuiltinCall } from './isReactBuiltinCall'; -export { default as isReactChildrenElementCall } from './isReactChildrenElementCall'; -export { default as isReactCloneElementCall } from './isReactCloneElementCall'; -export { default as isReactComponentClass } from './isReactComponentClass'; -export { default as isReactComponentMethod } from './isReactComponentMethod'; -export { default as isReactCreateClassCall } from './isReactCreateClassCall'; -export { default as isReactCreateElementCall } from './isReactCreateElementCall'; -export { default as isReactForwardRefCall } from './isReactForwardRefCall'; -export { default as isReactModuleName } from './isReactModuleName'; -export { default as isRequiredPropType } from './isRequiredPropType'; -export { default as isStatelessComponent } from './isStatelessComponent'; -export { default as isUnreachableFlowType } from './isUnreachableFlowType'; -export { default as match } from './match'; -export { default as normalizeClassDefinition } from './normalizeClassDefinition'; -export { default as parseJsDoc } from './parseJsDoc'; -export { default as postProcessDocumentation } from './postProcessDocumentation'; -export { default as printValue } from './printValue'; -export { default as resolveExportDeclaration } from './resolveExportDeclaration'; -export { default as resolveFunctionDefinitionToReturnValue } from './resolveFunctionDefinitionToReturnValue'; -export { default as resolveGenericTypeAnnotation } from './resolveGenericTypeAnnotation'; -export { default as resolveHOC } from './resolveHOC'; -export { default as resolveObjectPatternPropertyToValue } from './resolveObjectPatternPropertyToValue'; +} from './getTypeFromReactComponent.js'; +export { default as getTypeIdentifier } from './getTypeIdentifier.js'; +export { default as getTypeParameters } from './getTypeParameters.js'; +export type { TypeParameters } from './getTypeParameters.js'; +export { default as isDestructuringAssignment } from './isDestructuringAssignment.js'; +export { default as isExportsOrModuleAssignment } from './isExportsOrModuleAssignment.js'; +export { default as isReactBuiltinCall } from './isReactBuiltinCall.js'; +export { default as isReactChildrenElementCall } from './isReactChildrenElementCall.js'; +export { default as isReactCloneElementCall } from './isReactCloneElementCall.js'; +export { default as isReactComponentClass } from './isReactComponentClass.js'; +export { default as isReactComponentMethod } from './isReactComponentMethod.js'; +export { default as isReactCreateClassCall } from './isReactCreateClassCall.js'; +export { default as isReactCreateElementCall } from './isReactCreateElementCall.js'; +export { default as isReactForwardRefCall } from './isReactForwardRefCall.js'; +export { default as isReactModuleName } from './isReactModuleName.js'; +export { default as isRequiredPropType } from './isRequiredPropType.js'; +export { default as isStatelessComponent } from './isStatelessComponent.js'; +export { default as isUnreachableFlowType } from './isUnreachableFlowType.js'; +export { default as match } from './match.js'; +export { default as normalizeClassDefinition } from './normalizeClassDefinition.js'; +export { default as parseJsDoc } from './parseJsDoc.js'; +export { default as postProcessDocumentation } from './postProcessDocumentation.js'; +export { default as printValue } from './printValue.js'; +export { default as resolveExportDeclaration } from './resolveExportDeclaration.js'; +export { default as resolveFunctionDefinitionToReturnValue } from './resolveFunctionDefinitionToReturnValue.js'; +export { default as resolveGenericTypeAnnotation } from './resolveGenericTypeAnnotation.js'; +export { default as resolveHOC } from './resolveHOC.js'; +export { default as resolveObjectPatternPropertyToValue } from './resolveObjectPatternPropertyToValue.js'; export { default as resolveObjectKeysToArray, resolveObjectToNameArray, -} from './resolveObjectKeysToArray'; -export { default as resolveObjectValuesToArray } from './resolveObjectValuesToArray'; -export { default as resolveToModule } from './resolveToModule'; -export { default as resolveToValue } from './resolveToValue'; -export { default as setPropDescription } from './setPropDescription'; +} from './resolveObjectKeysToArray.js'; +export { default as resolveObjectValuesToArray } from './resolveObjectValuesToArray.js'; +export { default as resolveToModule } from './resolveToModule.js'; +export { default as resolveToValue } from './resolveToValue.js'; +export { default as setPropDescription } from './setPropDescription.js'; diff --git a/packages/react-docgen/src/utils/isExportsOrModuleAssignment.ts b/packages/react-docgen/src/utils/isExportsOrModuleAssignment.ts index d879b5cf509..a03d6134ec8 100644 --- a/packages/react-docgen/src/utils/isExportsOrModuleAssignment.ts +++ b/packages/react-docgen/src/utils/isExportsOrModuleAssignment.ts @@ -1,5 +1,5 @@ import type { NodePath } from '@babel/traverse'; -import * as expressionTo from './expressionTo'; +import * as expressionTo from './expressionTo.js'; /** * Returns true if the expression is of form `exports.foo = ...;` or diff --git a/packages/react-docgen/src/utils/isReactBuiltinCall.ts b/packages/react-docgen/src/utils/isReactBuiltinCall.ts index 0fc3cfde71a..b1bdb5a0287 100644 --- a/packages/react-docgen/src/utils/isReactBuiltinCall.ts +++ b/packages/react-docgen/src/utils/isReactBuiltinCall.ts @@ -1,8 +1,8 @@ -import isReactModuleName from './isReactModuleName'; -import match from './match'; -import resolveToModule from './resolveToModule'; -import resolveToValue from './resolveToValue'; -import isDestructuringAssignment from './isDestructuringAssignment'; +import isReactModuleName from './isReactModuleName.js'; +import match from './match.js'; +import resolveToModule from './resolveToModule.js'; +import resolveToValue from './resolveToValue.js'; +import isDestructuringAssignment from './isDestructuringAssignment.js'; import type { NodePath } from '@babel/traverse'; import type { CallExpression, MemberExpression } from '@babel/types'; diff --git a/packages/react-docgen/src/utils/isReactChildrenElementCall.ts b/packages/react-docgen/src/utils/isReactChildrenElementCall.ts index 5d997ef6195..47dd45b0739 100644 --- a/packages/react-docgen/src/utils/isReactChildrenElementCall.ts +++ b/packages/react-docgen/src/utils/isReactChildrenElementCall.ts @@ -1,8 +1,8 @@ import type { NodePath } from '@babel/traverse'; import type { MemberExpression } from '@babel/types'; -import isReactModuleName from './isReactModuleName'; -import match from './match'; -import resolveToModule from './resolveToModule'; +import isReactModuleName from './isReactModuleName.js'; +import match from './match.js'; +import resolveToModule from './resolveToModule.js'; // TODO unit tests diff --git a/packages/react-docgen/src/utils/isReactCloneElementCall.ts b/packages/react-docgen/src/utils/isReactCloneElementCall.ts index ce4265cade1..82b2fc9c819 100644 --- a/packages/react-docgen/src/utils/isReactCloneElementCall.ts +++ b/packages/react-docgen/src/utils/isReactCloneElementCall.ts @@ -1,6 +1,6 @@ import type { NodePath } from '@babel/traverse'; import type { Expression, ExpressionStatement } from '@babel/types'; -import isReactBuiltinCall from './isReactBuiltinCall'; +import isReactBuiltinCall from './isReactBuiltinCall.js'; /** * Returns true if the expression is a function call of the form diff --git a/packages/react-docgen/src/utils/isReactComponentClass.ts b/packages/react-docgen/src/utils/isReactComponentClass.ts index f099d610be7..b3e7aee62aa 100644 --- a/packages/react-docgen/src/utils/isReactComponentClass.ts +++ b/packages/react-docgen/src/utils/isReactComponentClass.ts @@ -5,11 +5,11 @@ import type { ClassExpression, ClassMethod, } from '@babel/types'; -import isReactModuleName from './isReactModuleName'; -import match from './match'; -import resolveToModule from './resolveToModule'; -import resolveToValue from './resolveToValue'; -import isDestructuringAssignment from './isDestructuringAssignment'; +import isReactModuleName from './isReactModuleName.js'; +import match from './match.js'; +import resolveToModule from './resolveToModule.js'; +import resolveToValue from './resolveToValue.js'; +import isDestructuringAssignment from './isDestructuringAssignment.js'; function isRenderMethod(path: NodePath): boolean { if ( diff --git a/packages/react-docgen/src/utils/isReactComponentMethod.ts b/packages/react-docgen/src/utils/isReactComponentMethod.ts index baddb146df7..ae23bd6b4ac 100644 --- a/packages/react-docgen/src/utils/isReactComponentMethod.ts +++ b/packages/react-docgen/src/utils/isReactComponentMethod.ts @@ -1,5 +1,5 @@ import type { NodePath } from '@babel/traverse'; -import getPropertyName from './getPropertyName'; +import getPropertyName from './getPropertyName.js'; const componentMethods = [ 'componentDidMount', diff --git a/packages/react-docgen/src/utils/isReactCreateClassCall.ts b/packages/react-docgen/src/utils/isReactCreateClassCall.ts index 944fdbf713e..65baf46b2d5 100644 --- a/packages/react-docgen/src/utils/isReactCreateClassCall.ts +++ b/packages/react-docgen/src/utils/isReactCreateClassCall.ts @@ -1,6 +1,6 @@ import type { NodePath } from '@babel/traverse'; -import resolveToModule from './resolveToModule'; -import isReactBuiltinCall from './isReactBuiltinCall'; +import resolveToModule from './resolveToModule.js'; +import isReactBuiltinCall from './isReactBuiltinCall.js'; /** * Returns true if the expression is a function call of the form diff --git a/packages/react-docgen/src/utils/isReactCreateElementCall.ts b/packages/react-docgen/src/utils/isReactCreateElementCall.ts index 51cc90270bb..ae8da566fcd 100644 --- a/packages/react-docgen/src/utils/isReactCreateElementCall.ts +++ b/packages/react-docgen/src/utils/isReactCreateElementCall.ts @@ -1,6 +1,6 @@ import type { NodePath } from '@babel/traverse'; import type { Expression, ExpressionStatement } from '@babel/types'; -import isReactBuiltinCall from './isReactBuiltinCall'; +import isReactBuiltinCall from './isReactBuiltinCall.js'; /** * Returns true if the expression is a function call of the form diff --git a/packages/react-docgen/src/utils/isReactForwardRefCall.ts b/packages/react-docgen/src/utils/isReactForwardRefCall.ts index c89e2284212..d81b8b275a4 100644 --- a/packages/react-docgen/src/utils/isReactForwardRefCall.ts +++ b/packages/react-docgen/src/utils/isReactForwardRefCall.ts @@ -1,5 +1,5 @@ import type { NodePath } from '@babel/traverse'; -import isReactBuiltinCall from './isReactBuiltinCall'; +import isReactBuiltinCall from './isReactBuiltinCall.js'; /** * Returns true if the expression is a function call of the form diff --git a/packages/react-docgen/src/utils/isRequiredPropType.ts b/packages/react-docgen/src/utils/isRequiredPropType.ts index b5ac307a7a0..6f0bf9a8445 100644 --- a/packages/react-docgen/src/utils/isRequiredPropType.ts +++ b/packages/react-docgen/src/utils/isRequiredPropType.ts @@ -1,5 +1,5 @@ import type { Node, NodePath } from '@babel/traverse'; -import getMembers from '../utils/getMembers'; +import getMembers from '../utils/getMembers.js'; /** * Returns true of the prop is required, according to its type definition diff --git a/packages/react-docgen/src/utils/isStatelessComponent.ts b/packages/react-docgen/src/utils/isStatelessComponent.ts index 842d3f62db0..4a563722b34 100644 --- a/packages/react-docgen/src/utils/isStatelessComponent.ts +++ b/packages/react-docgen/src/utils/isStatelessComponent.ts @@ -1,9 +1,9 @@ -import isReactCreateElementCall from './isReactCreateElementCall'; -import isReactCloneElementCall from './isReactCloneElementCall'; -import isReactChildrenElementCall from './isReactChildrenElementCall'; +import isReactCreateElementCall from './isReactCreateElementCall.js'; +import isReactCloneElementCall from './isReactCloneElementCall.js'; +import isReactChildrenElementCall from './isReactChildrenElementCall.js'; import type { NodePath } from '@babel/traverse'; -import type { StatelessComponentNode } from '../resolver'; -import findFunctionReturn from './findFunctionReturn'; +import type { StatelessComponentNode } from '../resolver/index.js'; +import findFunctionReturn from './findFunctionReturn.js'; const validPossibleStatelessComponentTypes = [ 'ArrowFunctionExpression', diff --git a/packages/react-docgen/src/utils/normalizeClassDefinition.ts b/packages/react-docgen/src/utils/normalizeClassDefinition.ts index fdec8cb9d79..58cba6ee83b 100644 --- a/packages/react-docgen/src/utils/normalizeClassDefinition.ts +++ b/packages/react-docgen/src/utils/normalizeClassDefinition.ts @@ -1,6 +1,6 @@ import { classProperty } from '@babel/types'; -import getMemberExpressionRoot from '../utils/getMemberExpressionRoot'; -import getMembers from '../utils/getMembers'; +import getMemberExpressionRoot from '../utils/getMemberExpressionRoot.js'; +import getMembers from '../utils/getMembers.js'; import type { NodePath } from '@babel/traverse'; import { visitors } from '@babel/traverse'; import type { @@ -8,7 +8,7 @@ import type { ClassExpression, Expression, } from '@babel/types'; -import { ignore } from './traverse'; +import { ignore } from './traverse.js'; interface TraverseState { readonly variableName: string; diff --git a/packages/react-docgen/src/utils/postProcessDocumentation.ts b/packages/react-docgen/src/utils/postProcessDocumentation.ts index 25511c572db..ff2f9a719a1 100644 --- a/packages/react-docgen/src/utils/postProcessDocumentation.ts +++ b/packages/react-docgen/src/utils/postProcessDocumentation.ts @@ -1,4 +1,4 @@ -import type { DocumentationObject } from '../Documentation'; +import type { DocumentationObject } from '../Documentation.js'; export default function ( documentation: DocumentationObject, diff --git a/packages/react-docgen/src/utils/resolveComponentDefinition.ts b/packages/react-docgen/src/utils/resolveComponentDefinition.ts index 22df7337e93..6d66f7f7f9f 100644 --- a/packages/react-docgen/src/utils/resolveComponentDefinition.ts +++ b/packages/react-docgen/src/utils/resolveComponentDefinition.ts @@ -1,11 +1,11 @@ import type { NodePath } from '@babel/traverse'; -import type { ComponentNode } from '../resolver'; -import isReactComponentClass from './isReactComponentClass'; -import isReactCreateClassCall from './isReactCreateClassCall'; -import isReactForwardRefCall from './isReactForwardRefCall'; -import isStatelessComponent from './isStatelessComponent'; -import normalizeClassDefinition from './normalizeClassDefinition'; -import resolveToValue from './resolveToValue'; +import type { ComponentNode } from '../resolver/index.js'; +import isReactComponentClass from './isReactComponentClass.js'; +import isReactCreateClassCall from './isReactCreateClassCall.js'; +import isReactForwardRefCall from './isReactForwardRefCall.js'; +import isStatelessComponent from './isStatelessComponent.js'; +import normalizeClassDefinition from './normalizeClassDefinition.js'; +import resolveToValue from './resolveToValue.js'; export function isComponentDefinition( path: NodePath, diff --git a/packages/react-docgen/src/utils/resolveExportDeclaration.ts b/packages/react-docgen/src/utils/resolveExportDeclaration.ts index 2973eb4ed65..cef5711fed3 100644 --- a/packages/react-docgen/src/utils/resolveExportDeclaration.ts +++ b/packages/react-docgen/src/utils/resolveExportDeclaration.ts @@ -1,4 +1,4 @@ -import resolveToValue from './resolveToValue'; +import resolveToValue from './resolveToValue.js'; import type { ExportDefaultDeclaration, ExportNamedDeclaration, diff --git a/packages/react-docgen/src/utils/resolveFunctionDefinitionToReturnValue.ts b/packages/react-docgen/src/utils/resolveFunctionDefinitionToReturnValue.ts index 48864379104..5732e8cf95e 100644 --- a/packages/react-docgen/src/utils/resolveFunctionDefinitionToReturnValue.ts +++ b/packages/react-docgen/src/utils/resolveFunctionDefinitionToReturnValue.ts @@ -1,8 +1,8 @@ import type { NodePath } from '@babel/traverse'; import { visitors } from '@babel/traverse'; import type { Expression, Function as BabelFunction } from '@babel/types'; -import resolveToValue from './resolveToValue'; -import { ignore, shallowIgnoreVisitors } from './traverse'; +import resolveToValue from './resolveToValue.js'; +import { ignore, shallowIgnoreVisitors } from './traverse.js'; interface TraverseState { returnPath?: NodePath; diff --git a/packages/react-docgen/src/utils/resolveGenericTypeAnnotation.ts b/packages/react-docgen/src/utils/resolveGenericTypeAnnotation.ts index b94d43e2a10..3b0c7267cb7 100644 --- a/packages/react-docgen/src/utils/resolveGenericTypeAnnotation.ts +++ b/packages/react-docgen/src/utils/resolveGenericTypeAnnotation.ts @@ -1,8 +1,8 @@ import type { NodePath } from '@babel/traverse'; -import isUnreachableFlowType from '../utils/isUnreachableFlowType'; -import resolveToValue from '../utils/resolveToValue'; -import { unwrapUtilityType } from './flowUtilityTypes'; -import getTypeIdentifier from './getTypeIdentifier'; +import isUnreachableFlowType from '../utils/isUnreachableFlowType.js'; +import resolveToValue from '../utils/resolveToValue.js'; +import { unwrapUtilityType } from './flowUtilityTypes.js'; +import getTypeIdentifier from './getTypeIdentifier.js'; function tryResolveGenericTypeAnnotation(path: NodePath): NodePath | undefined { let typePath = unwrapUtilityType(path); diff --git a/packages/react-docgen/src/utils/resolveHOC.ts b/packages/react-docgen/src/utils/resolveHOC.ts index 783a8dc267a..f51c68ea570 100644 --- a/packages/react-docgen/src/utils/resolveHOC.ts +++ b/packages/react-docgen/src/utils/resolveHOC.ts @@ -1,7 +1,7 @@ import type { NodePath } from '@babel/traverse'; -import isReactCreateClassCall from './isReactCreateClassCall'; -import isReactForwardRefCall from './isReactForwardRefCall'; -import resolveToValue from './resolveToValue'; +import isReactCreateClassCall from './isReactCreateClassCall.js'; +import isReactForwardRefCall from './isReactForwardRefCall.js'; +import resolveToValue from './resolveToValue.js'; /** * If the path is a call expression, it recursively resolves to the diff --git a/packages/react-docgen/src/utils/resolveObjectKeysToArray.ts b/packages/react-docgen/src/utils/resolveObjectKeysToArray.ts index a72428e2a06..08af4f2df6a 100644 --- a/packages/react-docgen/src/utils/resolveObjectKeysToArray.ts +++ b/packages/react-docgen/src/utils/resolveObjectKeysToArray.ts @@ -1,4 +1,4 @@ -import resolveToValue from './resolveToValue'; +import resolveToValue from './resolveToValue.js'; import type { NodePath } from '@babel/traverse'; import type { CallExpression, diff --git a/packages/react-docgen/src/utils/resolveObjectPatternPropertyToValue.ts b/packages/react-docgen/src/utils/resolveObjectPatternPropertyToValue.ts index 7abaae3c55a..c8304ce70e4 100644 --- a/packages/react-docgen/src/utils/resolveObjectPatternPropertyToValue.ts +++ b/packages/react-docgen/src/utils/resolveObjectPatternPropertyToValue.ts @@ -1,7 +1,7 @@ import type { NodePath } from '@babel/traverse'; import type { Identifier, ObjectProperty } from '@babel/types'; -import getPropertyValuePath from './getPropertyValuePath'; -import resolveToValue from './resolveToValue'; +import getPropertyValuePath from './getPropertyValuePath.js'; +import resolveToValue from './resolveToValue.js'; function resolveToObjectExpression(path: NodePath): NodePath | null { if (path.isVariableDeclarator()) { diff --git a/packages/react-docgen/src/utils/resolveObjectValuesToArray.ts b/packages/react-docgen/src/utils/resolveObjectValuesToArray.ts index 9a7b0f56dfa..10ed65a1249 100644 --- a/packages/react-docgen/src/utils/resolveObjectValuesToArray.ts +++ b/packages/react-docgen/src/utils/resolveObjectValuesToArray.ts @@ -1,4 +1,4 @@ -import resolveToValue from './resolveToValue'; +import resolveToValue from './resolveToValue.js'; import type { NodePath } from '@babel/traverse'; import type { CallExpression, diff --git a/packages/react-docgen/src/utils/resolveToModule.ts b/packages/react-docgen/src/utils/resolveToModule.ts index 1f2682a0530..26781e5a21c 100644 --- a/packages/react-docgen/src/utils/resolveToModule.ts +++ b/packages/react-docgen/src/utils/resolveToModule.ts @@ -1,7 +1,7 @@ import type { NodePath } from '@babel/traverse'; import type { Expression, StringLiteral } from '@babel/types'; -import getMemberExpressionRoot from './getMemberExpressionRoot'; -import resolveToValue from './resolveToValue'; +import getMemberExpressionRoot from './getMemberExpressionRoot.js'; +import resolveToValue from './resolveToValue.js'; /** * Given a path (e.g. call expression, member expression or identifier), diff --git a/packages/react-docgen/src/utils/resolveToValue.ts b/packages/react-docgen/src/utils/resolveToValue.ts index d0c173ebc31..fe3ff49ce94 100644 --- a/packages/react-docgen/src/utils/resolveToValue.ts +++ b/packages/react-docgen/src/utils/resolveToValue.ts @@ -1,15 +1,15 @@ import { Scope, visitors } from '@babel/traverse'; import type { NodePath } from '@babel/traverse'; import type { Identifier, ImportDeclaration } from '@babel/types'; -import getMemberExpressionRoot from './getMemberExpressionRoot'; -import getPropertyValuePath from './getPropertyValuePath'; -import { Array as toArray } from './expressionTo'; -import { shallowIgnoreVisitors } from './traverse'; +import getMemberExpressionRoot from './getMemberExpressionRoot.js'; +import getPropertyValuePath from './getPropertyValuePath.js'; +import { Array as toArray } from './expressionTo.js'; +import { shallowIgnoreVisitors } from './traverse.js'; import getMemberValuePath, { isSupportedDefinitionType, -} from './getMemberValuePath'; -import initialize from './ts-types'; -import getNameOrValue from './getNameOrValue'; +} from './getMemberValuePath.js'; +import initialize from './ts-types/index.js'; +import getNameOrValue from './getNameOrValue.js'; function findScopePath( bindingIdentifiers: Array>, diff --git a/packages/react-docgen/src/utils/setPropDescription.ts b/packages/react-docgen/src/utils/setPropDescription.ts index f54a30367e0..d6b023aea57 100644 --- a/packages/react-docgen/src/utils/setPropDescription.ts +++ b/packages/react-docgen/src/utils/setPropDescription.ts @@ -1,7 +1,7 @@ import type { NodePath } from '@babel/traverse'; -import type Documentation from '../Documentation'; -import getPropertyName from './getPropertyName'; -import { getDocblock } from './docblock'; +import type Documentation from '../Documentation.js'; +import getPropertyName from './getPropertyName.js'; +import { getDocblock } from './docblock.js'; import type { ObjectMethod, ObjectProperty, diff --git a/packages/react-docgen/tests/NodePathSerializer.js b/packages/react-docgen/tests/NodePathSerializer.js deleted file mode 100644 index 544728d0f49..00000000000 --- a/packages/react-docgen/tests/NodePathSerializer.js +++ /dev/null @@ -1,24 +0,0 @@ -const { NodePath } = require('@babel/traverse'); -const { removePropertiesDeep } = require('@babel/types'); - -function removeUndefinedProperties(node) { - for (const key of Object.keys(node)) { - if (node[key] === undefined) { - delete node[key]; - } else if (node[key] === Object(node[key])) { - node[key] = removeUndefinedProperties(node[key]); - } - } - - return node; -} - -module.exports = { - print(val, serialize) { - return serialize(removeUndefinedProperties(removePropertiesDeep(val.node))); - }, - - test(val) { - return val && val instanceof NodePath; - }, -}; diff --git a/packages/react-docgen/tests/integration/__fixtures__/component_33.tsx b/packages/react-docgen/tests/integration/__fixtures__/component_33.tsx index 7c8746ba7ee..c28397bfc11 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/component_33.tsx +++ b/packages/react-docgen/tests/integration/__fixtures__/component_33.tsx @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import ExtendedProps from './component_39'; +import ExtendedProps from './component_39.jsx'; /** * This is a typescript component with imported prop types diff --git a/packages/react-docgen/tests/integration/__fixtures__/component_34.js b/packages/react-docgen/tests/integration/__fixtures__/component_34.js index 4b227a5bc62..0001bf8c641 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/component_34.js +++ b/packages/react-docgen/tests/integration/__fixtures__/component_34.js @@ -1,4 +1,4 @@ -import Button from './component_6'; +import Button from './component_6.js'; import PropTypes from 'prop-types'; export function CustomButton({color, ...otherProps}) { diff --git a/packages/react-docgen/tests/integration/__fixtures__/component_35.js b/packages/react-docgen/tests/integration/__fixtures__/component_35.js index dfd50235b2f..35aa85afaf7 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/component_35.js +++ b/packages/react-docgen/tests/integration/__fixtures__/component_35.js @@ -1,4 +1,4 @@ -import {CustomButton, sharedProps} from './component_34'; +import {CustomButton, sharedProps} from './component_34.js'; import PropTypes from 'prop-types'; export function SuperCustomButton({color, ...otherProps}) { @@ -7,4 +7,4 @@ export function SuperCustomButton({color, ...otherProps}) { SuperCustomButton.propTypes = sharedProps; export {sharedProps}; -export * from './component_36'; +export * from './component_36.js'; diff --git a/packages/react-docgen/tests/integration/__fixtures__/component_36.js b/packages/react-docgen/tests/integration/__fixtures__/component_36.js index a27b2978d31..ae76d448c9f 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/component_36.js +++ b/packages/react-docgen/tests/integration/__fixtures__/component_36.js @@ -1,4 +1,4 @@ -import {SuperCustomButton, sharedProps} from './component_35'; +import {SuperCustomButton, sharedProps} from './component_35.js'; import PropTypes from 'prop-types'; export function SuperDuperCustomButton({color, ...otherProps}) { @@ -6,4 +6,4 @@ export function SuperDuperCustomButton({color, ...otherProps}) { } SuperDuperCustomButton.propTypes = sharedProps; -export * from './component_35'; +export * from './component_35.js'; diff --git a/packages/react-docgen/tests/integration/__fixtures__/component_37.js b/packages/react-docgen/tests/integration/__fixtures__/component_37.js index 6ccf696e961..2c92127a749 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/component_37.js +++ b/packages/react-docgen/tests/integration/__fixtures__/component_37.js @@ -1,4 +1,4 @@ -import * as C36 from './component_36'; +import * as C36 from './component_36.js'; import PropTypes from 'prop-types'; export function SuperDuperCustomButton({color, ...otherProps}) { @@ -6,4 +6,4 @@ export function SuperDuperCustomButton({color, ...otherProps}) { } SuperDuperCustomButton.propTypes = C36.sharedProps; -export {SuperCustomButton} from './component_36'; +export {SuperCustomButton} from './component_36.js'; diff --git a/packages/react-docgen/tests/integration/__fixtures__/component_38.js b/packages/react-docgen/tests/integration/__fixtures__/component_38.js index c73fde28d1b..27b4f012378 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/component_38.js +++ b/packages/react-docgen/tests/integration/__fixtures__/component_38.js @@ -1,4 +1,4 @@ -import {SuperCustomButton} from './component_37'; +import {SuperCustomButton} from './component_37.js'; import PropTypes from 'prop-types'; export function SuperDuperCustomButton({color, ...otherProps}) { diff --git a/packages/react-docgen/tests/integration/__fixtures__/component_39.tsx b/packages/react-docgen/tests/integration/__fixtures__/component_39.tsx index 96670896753..32ca3239943 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/component_39.tsx +++ b/packages/react-docgen/tests/integration/__fixtures__/component_39.tsx @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Props as ImportedProps } from './component_27'; +import { Props as ImportedProps } from './component_27.jsx'; export default interface ExtendedProps extends ImportedProps { bar: number diff --git a/packages/react-docgen/tests/integration/__fixtures__/component_40.js b/packages/react-docgen/tests/integration/__fixtures__/component_40.js index f9d7480923d..f4acc574fad 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/component_40.js +++ b/packages/react-docgen/tests/integration/__fixtures__/component_40.js @@ -1,4 +1,4 @@ -import { Sizes } from '../common'; +import { Sizes } from '../common.js'; import T from 'prop-types'; function SuperDuperCustomButton() { diff --git a/packages/react-docgen/tests/integration/__fixtures__/flow-import-type.js b/packages/react-docgen/tests/integration/__fixtures__/flow-import-type.js index 5886c940489..c5a4dfec45e 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/flow-import-type.js +++ b/packages/react-docgen/tests/integration/__fixtures__/flow-import-type.js @@ -3,7 +3,7 @@ */ import React, { Component } from 'react'; -import type { Props as ImportedProps } from './flow-export-type'; +import type { Props as ImportedProps } from './flow-export-type.js'; export type ExtendedProps = { ...ImportedProps, diff --git a/packages/react-docgen/tests/integration/__fixtures__/flow-spread-import-type.js b/packages/react-docgen/tests/integration/__fixtures__/flow-spread-import-type.js index 6b02ffabf52..d7917c8d926 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/flow-spread-import-type.js +++ b/packages/react-docgen/tests/integration/__fixtures__/flow-spread-import-type.js @@ -3,7 +3,7 @@ */ import React, { Component } from 'react'; -import type {ExtendedProps} from './flow-import-type'; +import type {ExtendedProps} from './flow-import-type.js'; /** * This is a Flow component with imported prop types diff --git a/packages/react-docgen/tests/integration/__fixtures__/support/some-exports.ts b/packages/react-docgen/tests/integration/__fixtures__/support/some-exports.ts index 72133053ff2..75178b1edae 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/support/some-exports.ts +++ b/packages/react-docgen/tests/integration/__fixtures__/support/some-exports.ts @@ -2,4 +2,4 @@ const obj = { objDestruct: "string" }; export const { objDestruct } = obj; -export defaultFrom from './other-exports'; +export defaultFrom from './other-exports.js'; diff --git a/packages/react-docgen/tests/integration/__fixtures__/test-all-imports.tsx b/packages/react-docgen/tests/integration/__fixtures__/test-all-imports.tsx index 837cfb3dc95..a2686d0f6cf 100644 --- a/packages/react-docgen/tests/integration/__fixtures__/test-all-imports.tsx +++ b/packages/react-docgen/tests/integration/__fixtures__/test-all-imports.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { objDestruct, defaultFrom } from './support/some-exports'; +import { objDestruct, defaultFrom } from './support/some-exports.js'; /** * This is a TS component with imported stuff diff --git a/packages/react-docgen/tests/integration/__snapshots__/integration-test.ts.snap b/packages/react-docgen/tests/integration/__snapshots__/integration-test.ts.snap index 526dbed56b2..ada4d283d1b 100644 --- a/packages/react-docgen/tests/integration/__snapshots__/integration-test.ts.snap +++ b/packages/react-docgen/tests/integration/__snapshots__/integration-test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1 -exports[`integration fixtures processes component "class-without-id.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "class-without-id.tsx" without errors 1`] = ` [ { "description": "", @@ -18,7 +18,7 @@ exports[`integration fixtures processes component "class-without-id.tsx" without ] `; -exports[`integration fixtures processes component "component_1.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_1.js" without errors 1`] = ` [ { "description": "The is a component to test the document generation", @@ -28,7 +28,7 @@ exports[`integration fixtures processes component "component_1.js" without error ] `; -exports[`integration fixtures processes component "component_2.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_2.js" without errors 1`] = ` [ { "description": "", @@ -59,7 +59,7 @@ exports[`integration fixtures processes component "component_2.js" without error "type": { "defaultValue": { "computed": false, - "value": ""primary"", + "value": "\\"primary\\"", }, "required": false, }, @@ -68,7 +68,7 @@ exports[`integration fixtures processes component "component_2.js" without error ] `; -exports[`integration fixtures processes component "component_3.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_3.js" without errors 1`] = ` [ { "description": "", @@ -87,7 +87,7 @@ exports[`integration fixtures processes component "component_3.js" without error ] `; -exports[`integration fixtures processes component "component_4.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_4.js" without errors 1`] = ` [ { "description": "", @@ -150,7 +150,7 @@ exports[`integration fixtures processes component "component_4.js" without error ] `; -exports[`integration fixtures processes component "component_5.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_5.js" without errors 1`] = ` [ { "childContext": { @@ -203,7 +203,7 @@ exports[`integration fixtures processes component "component_5.js" without error ] `; -exports[`integration fixtures processes component "component_6.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_6.js" without errors 1`] = ` [ { "childContext": { @@ -256,7 +256,7 @@ exports[`integration fixtures processes component "component_6.js" without error ] `; -exports[`integration fixtures processes component "component_7.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_7.js" without errors 1`] = ` [ { "description": "The is a component to test the document generation", @@ -266,7 +266,7 @@ exports[`integration fixtures processes component "component_7.js" without error ] `; -exports[`integration fixtures processes component "component_8.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_8.js" without errors 1`] = ` [ { "description": "", @@ -290,7 +290,7 @@ exports[`integration fixtures processes component "component_8.js" without error ] `; -exports[`integration fixtures processes component "component_9.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_9.js" without errors 1`] = ` [ { "description": "Should be recognized as component.", @@ -300,7 +300,7 @@ exports[`integration fixtures processes component "component_9.js" without error ] `; -exports[`integration fixtures processes component "component_10.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_10.js" without errors 1`] = ` [ { "description": "React component that display current time at current location.", @@ -321,7 +321,7 @@ exports[`integration fixtures processes component "component_10.js" without erro @returns {Object} currentTime @returns {int} currentTime.hour @returns {int} currentTime.minutes - @returns {string} currentTime.ampm "am" or "pm" + @returns {string} currentTime.ampm \\"am\\" or \\"pm\\" @returns {string} currentTime.dayOfWeek @returns {string} currentTime.month @returns {int} currentTime.date", @@ -347,8 +347,8 @@ exports[`integration fixtures processes component "component_10.js" without erro "props": { "title": { "description": "A text display current's user identity, - "Nobody" if no one is detected in the background, - "Hi, ..name" if an user is detected", + \\"Nobody\\" if no one is detected in the background, + \\"Hi, ..name\\" if an user is detected", "required": false, "type": { "name": "string", @@ -359,7 +359,7 @@ exports[`integration fixtures processes component "component_10.js" without erro ] `; -exports[`integration fixtures processes component "component_11.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_11.js" without errors 1`] = ` [ { "composes": [ @@ -395,7 +395,7 @@ exports[`integration fixtures processes component "component_11.js" without erro ] `; -exports[`integration fixtures processes component "component_12.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_12.js" without errors 1`] = ` [ { "description": "", @@ -596,7 +596,7 @@ Set to 'auto' to automatically calculate transition time based on height.", ] `; -exports[`integration fixtures processes component "component_13.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_13.js" without errors 1`] = ` [ { "description": "", @@ -617,23 +617,23 @@ exports[`integration fixtures processes component "component_13.js" without erro "elements": [ { "name": "literal", - "value": ""left"", + "value": "\\"left\\"", }, { "name": "literal", - "value": ""center"", + "value": "\\"center\\"", }, { "name": "literal", - "value": ""right"", + "value": "\\"right\\"", }, { "name": "literal", - "value": ""justify"", + "value": "\\"justify\\"", }, ], "name": "union", - "raw": ""left" | "center" | "right" | "justify"", + "raw": "\\"left\\" | \\"center\\" | \\"right\\" | \\"justify\\"", }, "required": false, }, @@ -686,23 +686,23 @@ exports[`integration fixtures processes component "component_13.js" without erro "elements": [ { "name": "literal", - "value": ""none"", + "value": "\\"none\\"", }, { "name": "literal", - "value": ""tight"", + "value": "\\"tight\\"", }, { "name": "literal", - "value": ""normal"", + "value": "\\"normal\\"", }, { "name": "literal", - "value": ""loose"", + "value": "\\"loose\\"", }, ], "name": "union", - "raw": ""none" | "tight" | "normal" | "loose"", + "raw": "\\"none\\" | \\"tight\\" | \\"normal\\" | \\"loose\\"", }, "required": false, }, @@ -775,19 +775,19 @@ exports[`integration fixtures processes component "component_13.js" without erro "elements": [ { "name": "literal", - "value": ""tight"", + "value": "\\"tight\\"", }, { "name": "literal", - "value": ""normal"", + "value": "\\"normal\\"", }, { "name": "literal", - "value": ""wide"", + "value": "\\"wide\\"", }, ], "name": "union", - "raw": ""tight" | "normal" | "wide"", + "raw": "\\"tight\\" | \\"normal\\" | \\"wide\\"", }, "required": false, }, @@ -818,19 +818,19 @@ exports[`integration fixtures processes component "component_13.js" without erro "elements": [ { "name": "literal", - "value": ""lowercase"", + "value": "\\"lowercase\\"", }, { "name": "literal", - "value": ""uppercase"", + "value": "\\"uppercase\\"", }, { "name": "literal", - "value": ""capitalize"", + "value": "\\"capitalize\\"", }, ], "name": "union", - "raw": ""lowercase" | "uppercase" | "capitalize"", + "raw": "\\"lowercase\\" | \\"uppercase\\" | \\"capitalize\\"", }, "required": false, }, @@ -853,7 +853,7 @@ exports[`integration fixtures processes component "component_13.js" without erro ] `; -exports[`integration fixtures processes component "component_14.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_14.js" without errors 1`] = ` [ { "description": "", @@ -873,7 +873,7 @@ exports[`integration fixtures processes component "component_14.js" without erro ] `; -exports[`integration fixtures processes component "component_15.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_15.js" without errors 1`] = ` [ { "composes": [ @@ -938,7 +938,7 @@ exports[`integration fixtures processes component "component_15.js" without erro ] `; -exports[`integration fixtures processes component "component_16.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_16.js" without errors 1`] = ` [ { "description": "", @@ -962,7 +962,7 @@ exports[`integration fixtures processes component "component_16.js" without erro ] `; -exports[`integration fixtures processes component "component_17.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_17.js" without errors 1`] = ` [ { "description": "", @@ -1026,7 +1026,7 @@ exports[`integration fixtures processes component "component_17.js" without erro ] `; -exports[`integration fixtures processes component "component_18.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_18.js" without errors 1`] = ` [ { "description": "", @@ -1060,7 +1060,7 @@ exports[`integration fixtures processes component "component_18.js" without erro ] `; -exports[`integration fixtures processes component "component_19.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_19.js" without errors 1`] = ` [ { "description": "", @@ -1085,7 +1085,7 @@ exports[`integration fixtures processes component "component_19.js" without erro ] `; -exports[`integration fixtures processes component "component_20.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_20.js" without errors 1`] = ` [ { "description": "", @@ -1095,7 +1095,7 @@ exports[`integration fixtures processes component "component_20.js" without erro "@computed#children": { "defaultValue": { "computed": false, - "value": ""default"", + "value": "\\"default\\"", }, "description": "This is a test", "required": false, @@ -1108,7 +1108,7 @@ exports[`integration fixtures processes component "component_20.js" without erro ] `; -exports[`integration fixtures processes component "component_21.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_21.tsx" without errors 1`] = ` [ { "description": "This is a typescript class component", @@ -1174,7 +1174,7 @@ exports[`integration fixtures processes component "component_21.tsx" without err ] `; -exports[`integration fixtures processes component "component_22.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_22.tsx" without errors 1`] = ` [ { "description": "This is a TypeScript function component", @@ -1188,23 +1188,23 @@ exports[`integration fixtures processes component "component_22.tsx" without err "elements": [ { "name": "literal", - "value": ""left"", + "value": "\\"left\\"", }, { "name": "literal", - "value": ""center"", + "value": "\\"center\\"", }, { "name": "literal", - "value": ""right"", + "value": "\\"right\\"", }, { "name": "literal", - "value": ""justify"", + "value": "\\"justify\\"", }, ], "name": "union", - "raw": ""left" | "center" | "right" | "justify"", + "raw": "\\"left\\" | \\"center\\" | \\"right\\" | \\"justify\\"", }, }, "center": { @@ -1278,7 +1278,7 @@ exports[`integration fixtures processes component "component_22.tsx" without err ] `; -exports[`integration fixtures processes component "component_23.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_23.tsx" without errors 1`] = ` [ { "composes": [ @@ -1347,7 +1347,7 @@ exports[`integration fixtures processes component "component_23.tsx" without err ] `; -exports[`integration fixtures processes component "component_24.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_24.js" without errors 1`] = ` [ { "composes": [ @@ -1416,7 +1416,7 @@ exports[`integration fixtures processes component "component_24.js" without erro ] `; -exports[`integration fixtures processes component "component_25.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_25.tsx" without errors 1`] = ` [ { "description": "This is a typescript class component", @@ -1455,7 +1455,7 @@ exports[`integration fixtures processes component "component_25.tsx" without err ] `; -exports[`integration fixtures processes component "component_26.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_26.js" without errors 1`] = ` [ { "description": "This is a typescript class component", @@ -1494,7 +1494,7 @@ exports[`integration fixtures processes component "component_26.js" without erro ] `; -exports[`integration fixtures processes component "component_27.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_27.tsx" without errors 1`] = ` [ { "description": "This is a typescript class component", @@ -1554,7 +1554,7 @@ exports[`integration fixtures processes component "component_27.tsx" without err ] `; -exports[`integration fixtures processes component "component_28.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_28.tsx" without errors 1`] = ` [ { "description": "Example component description", @@ -1577,7 +1577,7 @@ exports[`integration fixtures processes component "component_28.tsx" without err ] `; -exports[`integration fixtures processes component "component_29.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_29.js" without errors 1`] = ` [ { "description": "", @@ -1596,7 +1596,7 @@ exports[`integration fixtures processes component "component_29.js" without erro ] `; -exports[`integration fixtures processes component "component_30.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_30.js" without errors 1`] = ` [ { "description": "", @@ -1615,7 +1615,7 @@ exports[`integration fixtures processes component "component_30.js" without erro ] `; -exports[`integration fixtures processes component "component_31.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_31.js" without errors 1`] = ` [ { "description": "", @@ -1634,7 +1634,7 @@ exports[`integration fixtures processes component "component_31.js" without erro ] `; -exports[`integration fixtures processes component "component_32.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_32.js" without errors 1`] = ` [ { "description": "", @@ -1697,7 +1697,7 @@ exports[`integration fixtures processes component "component_32.js" without erro ] `; -exports[`integration fixtures processes component "component_33.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_33.tsx" without errors 1`] = ` [ { "description": "This is a typescript component with imported prop types", @@ -1723,7 +1723,7 @@ exports[`integration fixtures processes component "component_33.tsx" without err ] `; -exports[`integration fixtures processes component "component_34.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_34.js" without errors 1`] = ` [ { "description": "", @@ -1763,7 +1763,7 @@ exports[`integration fixtures processes component "component_34.js" without erro ] `; -exports[`integration fixtures processes component "component_35.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_35.js" without errors 1`] = ` [ { "description": "", @@ -1796,7 +1796,7 @@ exports[`integration fixtures processes component "component_35.js" without erro ] `; -exports[`integration fixtures processes component "component_36.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_36.js" without errors 1`] = ` [ { "description": "", @@ -1829,7 +1829,7 @@ exports[`integration fixtures processes component "component_36.js" without erro ] `; -exports[`integration fixtures processes component "component_37.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_37.js" without errors 1`] = ` [ { "description": "", @@ -1862,7 +1862,7 @@ exports[`integration fixtures processes component "component_37.js" without erro ] `; -exports[`integration fixtures processes component "component_38.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_38.js" without errors 1`] = ` [ { "description": "", @@ -1895,7 +1895,7 @@ exports[`integration fixtures processes component "component_38.js" without erro ] `; -exports[`integration fixtures processes component "component_39.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_39.tsx" without errors 1`] = ` [ { "description": "This is a typescript component with imported prop types", @@ -1914,7 +1914,7 @@ exports[`integration fixtures processes component "component_39.tsx" without err ] `; -exports[`integration fixtures processes component "component_40.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_40.js" without errors 1`] = ` [ { "description": "", @@ -1939,7 +1939,7 @@ exports[`integration fixtures processes component "component_40.js" without erro ] `; -exports[`integration fixtures processes component "component_41.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_41.tsx" without errors 1`] = ` [ { "description": "", @@ -1959,7 +1959,7 @@ exports[`integration fixtures processes component "component_41.tsx" without err ] `; -exports[`integration fixtures processes component "component_42.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_42.js" without errors 1`] = ` [ { "description": "", @@ -1977,7 +1977,7 @@ exports[`integration fixtures processes component "component_42.js" without erro ] `; -exports[`integration fixtures processes component "component_43.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "component_43.tsx" without errors 1`] = ` [ { "description": "", @@ -2017,7 +2017,7 @@ exports[`integration fixtures processes component "component_43.tsx" without err ] `; -exports[`integration fixtures processes component "flow-export-type.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "flow-export-type.js" without errors 1`] = ` [ { "description": "This is a Flow class component", @@ -2075,7 +2075,7 @@ exports[`integration fixtures processes component "flow-export-type.js" without ] `; -exports[`integration fixtures processes component "flow-import-type.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "flow-import-type.js" without errors 1`] = ` [ { "description": "This is a Flow component with imported prop types", @@ -2094,7 +2094,7 @@ exports[`integration fixtures processes component "flow-import-type.js" without ] `; -exports[`integration fixtures processes component "flow-spread-import-type.js" without errors 1`] = ` +exports[`integration > fixtures > processes component "flow-spread-import-type.js" without errors 1`] = ` [ { "description": "This is a Flow component with imported prop types", @@ -2120,7 +2120,7 @@ exports[`integration fixtures processes component "flow-spread-import-type.js" w ] `; -exports[`integration fixtures processes component "test-all-imports.tsx" without errors 1`] = ` +exports[`integration > fixtures > processes component "test-all-imports.tsx" without errors 1`] = ` [ { "description": "This is a TS component with imported stuff", @@ -2130,7 +2130,7 @@ exports[`integration fixtures processes component "test-all-imports.tsx" without "x": { "defaultValue": { "computed": false, - "value": ""string"", + "value": "\\"string\\"", }, "required": false, }, diff --git a/packages/react-docgen/tests/integration/integration-test.ts b/packages/react-docgen/tests/integration/integration-test.ts index 16fa9011920..125e3faa494 100644 --- a/packages/react-docgen/tests/integration/integration-test.ts +++ b/packages/react-docgen/tests/integration/integration-test.ts @@ -1,10 +1,15 @@ import fs from 'fs'; -import path from 'path'; +import { dirname, join } from 'path'; +import { describe, expect, test } from 'vitest'; import { parse, importers } from '../../src/main'; +import { fileURLToPath } from 'url'; describe('integration', () => { describe('fixtures', () => { - const fixturePath = path.join(__dirname, '__fixtures__'); + const fixturePath = join( + dirname(fileURLToPath(import.meta.url)), + '__fixtures__', + ); const fileNames = fs.readdirSync(fixturePath, { withFileTypes: true }); for (let i = 0; i < fileNames.length; i++) { @@ -13,10 +18,10 @@ describe('integration', () => { } const name = fileNames[i].name; - const filePath = path.join(fixturePath, name); + const filePath = join(fixturePath, name); const fileContent = fs.readFileSync(filePath, 'utf8'); - it(`processes component "${name}" without errors`, () => { + test(`processes component "${name}" without errors`, () => { let result; expect(() => { diff --git a/packages/react-docgen/tests/setupTestFramework.ts b/packages/react-docgen/tests/setupTestFramework.ts deleted file mode 100644 index 7f36e0b562b..00000000000 --- a/packages/react-docgen/tests/setupTestFramework.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* eslint-env jest */ -import type { Node } from '@babel/traverse'; -import { NodePath } from '@babel/traverse'; -import { isNodesEquivalent, removePropertiesDeep } from '@babel/types'; -import { diff } from 'jest-diff'; -import { printExpected, printReceived } from 'jest-matcher-utils'; - -const matchers = { - toEqualASTNode: function (received: NodePath, expected: Node | NodePath) { - if (!expected || typeof expected !== 'object') { - throw new Error( - 'Expected value must be an object representing an AST node.\n' + - 'Got ' + - expected + - '(' + - typeof expected + - ') instead.', - ); - } - - // Use value here instead of node, as node has some magic and always returns - // the next Node it finds even if value is an array - const receivedNode = received.node; - let expectedNode: Node; - - if (expected instanceof NodePath) { - expectedNode = expected.node; - } else { - expectedNode = expected; - } - if (expectedNode.type === 'MemberExpression') { - // Babel 7 always adds this optional field which is wrong - // Fixed in babel v8 - delete expectedNode.optional; - } - - return { - pass: isNodesEquivalent(receivedNode, expectedNode), - message: () => { - removePropertiesDeep(expectedNode); - removePropertiesDeep(receivedNode); - const diffString = diff(expectedNode, receivedNode); - - return ( - 'Expected value to be:\n' + - ` ${printExpected(expectedNode)}\n` + - 'Received:\n' + - ` ${printReceived(receivedNode)}` + - (diffString ? `\n\nDifference:\n\n${diffString}` : '') - ); - }, - }; - }, -}; - -expect.extend(matchers); diff --git a/packages/react-docgen/tests/utils.ts b/packages/react-docgen/tests/utils.ts index 4344c13a4da..ccdbff1ed17 100644 --- a/packages/react-docgen/tests/utils.ts +++ b/packages/react-docgen/tests/utils.ts @@ -1,8 +1,8 @@ import type { Node, TransformOptions } from '@babel/core'; import type { NodePath } from '@babel/traverse'; -import type { Importer, ImportPath } from '../src/importer'; -import FileState from '../src/FileState'; -import babelParse from '../src/babelParser'; +import type { Importer, ImportPath } from '../src/importer/index.js'; +import FileState from '../src/FileState.js'; +import babelParse from '../src/babelParser.js'; import type { ExportDefaultDeclaration, Expression, @@ -10,16 +10,7 @@ import type { Program, Statement, } from '@babel/types'; - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace jest { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - interface Matchers { - toEqualASTNode: (expected: Node | NodePath) => CustomMatcherResult; - } - } -} +import { afterEach } from 'vitest'; interface ParseCall { (code: string, importer: Importer): NodePath; diff --git a/renovate.json b/renovate.json index dd3fad296dc..b1ed8cb43f2 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,7 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "labels": ["dependencies"], - "extends": ["config:base", "group:jestPlusTSJest", "group:jestPlusTypes"], + "extends": ["config:base"], "baseBranches": ["main", "5.x"], "enabled": true, "lockFileMaintenance": { diff --git a/tests/NodePathSerializer.ts b/tests/NodePathSerializer.ts new file mode 100644 index 00000000000..70ed6dcfc72 --- /dev/null +++ b/tests/NodePathSerializer.ts @@ -0,0 +1,31 @@ +import { NodePath } from '@babel/traverse'; +import { removePropertiesDeep } from '@babel/types'; +import type { expect } from 'vitest'; + +function removeUndefinedProperties(node) { + for (const key of Object.keys(node)) { + if (node[key] === undefined) { + delete node[key]; + } else if (node[key] === Object(node[key])) { + node[key] = removeUndefinedProperties(node[key]); + } + } + + return node; +} + +export default { + serialize(val, config, indentation, depth, refs, printer) { + return printer( + removeUndefinedProperties(removePropertiesDeep(val.node)), + config, + indentation, + depth, + refs, + ); + }, + + test(val) { + return val && val instanceof NodePath; + }, +} as Parameters[0]; diff --git a/tests/setupTestFramework.ts b/tests/setupTestFramework.ts new file mode 100644 index 00000000000..a667973cb46 --- /dev/null +++ b/tests/setupTestFramework.ts @@ -0,0 +1,4 @@ +import NodePathSerializer from './NodePathSerializer.js'; +import { expect } from 'vitest'; + +expect.addSnapshotSerializer(NodePathSerializer); diff --git a/tsconfig.base.json b/tsconfig.base.json index a199f242d32..0f5e01db693 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -4,7 +4,7 @@ "declaration": true, "lib": ["es2020"], "target": "es2020", - "module": "commonjs", + "module": "es2020", "strict": true, "strictNullChecks": true, "noImplicitThis": true, @@ -12,7 +12,7 @@ "noImplicitReturns": true, "noUnusedParameters": true, "noUnusedLocals": true, - "moduleResolution": "node", + "moduleResolution": "node16", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "inlineSourceMap": false, diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 00000000000..969c4eb21ae --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,16 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + setupFiles: ['./tests/setupTestFramework.ts'], + include: ['**/__tests__/**/*-test.ts', '**/tests/integration/**/*-test.ts'], + testTimeout: 30_000, + deps: { + interopDefault: false, + }, + coverage: { + provider: 'c8', + reporter: ['text', 'lcov'], + }, + }, +}); diff --git a/website/src/components/App.js b/website/src/components/App.js index 6eb86b25518..99cd257dc89 100644 --- a/website/src/components/App.js +++ b/website/src/components/App.js @@ -1,6 +1,6 @@ import React from 'react'; -import Panel from './CodeMirrorPanel'; -import Header from './Header'; +import Panel from './CodeMirrorPanel.js'; +import Header from './Header.js'; import { parse } from 'react-docgen'; const codeSample = `import React, { Component } from 'react'; diff --git a/website/src/index.js b/website/src/index.js index 8ec666527e4..2b6d3da5130 100644 --- a/website/src/index.js +++ b/website/src/index.js @@ -1,7 +1,7 @@ import 'process'; import React from 'react'; import * as ReactDOMClient from 'react-dom/client'; -import App from './components/App'; +import App from './components/App.js'; import 'codemirror/lib/codemirror.css'; import './react-docgen.less'; diff --git a/website/webpack.config.js b/website/webpack.config.js index 7e300710b44..1d64235cd34 100644 --- a/website/webpack.config.js +++ b/website/webpack.config.js @@ -104,12 +104,6 @@ module.exports = { path: require.resolve('path-browserify'), process: require.resolve('process/browser'), }, - alias: { - 'react-docgen': path.resolve( - __dirname, - '../packages/react-docgen/src/main.ts', - ), - }, }, plugins, }; diff --git a/yarn.lock b/yarn.lock index 2cc2144794e..70fdab1f6fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,7 +15,7 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.18.6": +"@babel/code-frame@npm:^7.18.6": version: 7.18.6 resolution: "@babel/code-frame@npm:7.18.6" dependencies: @@ -31,7 +31,7 @@ __metadata: languageName: node linkType: hard -"@babel/core@npm:7.20.2, @babel/core@npm:^7.0.0, @babel/core@npm:^7.11.6, @babel/core@npm:^7.12.3, @babel/core@npm:^7.18.9, @babel/core@npm:^7.7.5": +"@babel/core@npm:7.20.2, @babel/core@npm:^7.0.0, @babel/core@npm:^7.18.9, @babel/core@npm:^7.7.5": version: 7.20.2 resolution: "@babel/core@npm:7.20.2" dependencies: @@ -68,7 +68,7 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:^7.12.11, @babel/generator@npm:^7.20.1, @babel/generator@npm:^7.20.2, @babel/generator@npm:^7.7.2": +"@babel/generator@npm:^7.12.11, @babel/generator@npm:^7.20.1, @babel/generator@npm:^7.20.2": version: 7.20.4 resolution: "@babel/generator@npm:7.20.4" dependencies: @@ -351,7 +351,7 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.18.10, @babel/parser@npm:^7.20.1, @babel/parser@npm:^7.20.2": +"@babel/parser@npm:^7.18.10, @babel/parser@npm:^7.20.1, @babel/parser@npm:^7.20.2": version: 7.20.3 resolution: "@babel/parser@npm:7.20.3" bin: @@ -584,18 +584,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-bigint@npm:^7.8.3": - version: 7.8.3 - resolution: "@babel/plugin-syntax-bigint@npm:7.8.3" - dependencies: - "@babel/helper-plugin-utils": ^7.8.0 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: 3a10849d83e47aec50f367a9e56a6b22d662ddce643334b087f9828f4c3dd73bdc5909aaeabe123fed78515767f9ca43498a0e621c438d1cd2802d7fae3c9648 - languageName: node - linkType: hard - -"@babel/plugin-syntax-class-properties@npm:^7.12.13, @babel/plugin-syntax-class-properties@npm:^7.8.3": +"@babel/plugin-syntax-class-properties@npm:^7.12.13": version: 7.12.13 resolution: "@babel/plugin-syntax-class-properties@npm:7.12.13" dependencies: @@ -650,17 +639,6 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-import-meta@npm:^7.8.3": - version: 7.10.4 - resolution: "@babel/plugin-syntax-import-meta@npm:7.10.4" - dependencies: - "@babel/helper-plugin-utils": ^7.10.4 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: 166ac1125d10b9c0c430e4156249a13858c0366d38844883d75d27389621ebe651115cb2ceb6dc011534d5055719fa1727b59f39e1ab3ca97820eef3dcab5b9b - languageName: node - linkType: hard - "@babel/plugin-syntax-json-strings@npm:^7.8.3": version: 7.8.3 resolution: "@babel/plugin-syntax-json-strings@npm:7.8.3" @@ -672,7 +650,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-jsx@npm:^7.18.6, @babel/plugin-syntax-jsx@npm:^7.7.2": +"@babel/plugin-syntax-jsx@npm:^7.18.6": version: 7.18.6 resolution: "@babel/plugin-syntax-jsx@npm:7.18.6" dependencies: @@ -683,7 +661,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-logical-assignment-operators@npm:^7.10.4, @babel/plugin-syntax-logical-assignment-operators@npm:^7.8.3": +"@babel/plugin-syntax-logical-assignment-operators@npm:^7.10.4": version: 7.10.4 resolution: "@babel/plugin-syntax-logical-assignment-operators@npm:7.10.4" dependencies: @@ -705,7 +683,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-numeric-separator@npm:^7.10.4, @babel/plugin-syntax-numeric-separator@npm:^7.8.3": +"@babel/plugin-syntax-numeric-separator@npm:^7.10.4": version: 7.10.4 resolution: "@babel/plugin-syntax-numeric-separator@npm:7.10.4" dependencies: @@ -760,7 +738,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-top-level-await@npm:^7.14.5, @babel/plugin-syntax-top-level-await@npm:^7.8.3": +"@babel/plugin-syntax-top-level-await@npm:^7.14.5": version: 7.14.5 resolution: "@babel/plugin-syntax-top-level-await@npm:7.14.5" dependencies: @@ -771,7 +749,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-typescript@npm:^7.20.0, @babel/plugin-syntax-typescript@npm:^7.7.2": +"@babel/plugin-syntax-typescript@npm:^7.20.0": version: 7.20.0 resolution: "@babel/plugin-syntax-typescript@npm:7.20.0" dependencies: @@ -1360,7 +1338,7 @@ __metadata: languageName: node linkType: hard -"@babel/template@npm:^7.18.10, @babel/template@npm:^7.3.3": +"@babel/template@npm:^7.18.10": version: 7.18.10 resolution: "@babel/template@npm:7.18.10" dependencies: @@ -1371,7 +1349,7 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.1.6, @babel/traverse@npm:^7.18.9, @babel/traverse@npm:^7.19.0, @babel/traverse@npm:^7.19.1, @babel/traverse@npm:^7.20.1, @babel/traverse@npm:^7.7.2": +"@babel/traverse@npm:^7.1.6, @babel/traverse@npm:^7.18.9, @babel/traverse@npm:^7.19.0, @babel/traverse@npm:^7.19.1, @babel/traverse@npm:^7.20.1": version: 7.20.1 resolution: "@babel/traverse@npm:7.20.1" dependencies: @@ -1389,7 +1367,7 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.18.10, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.9, @babel/types@npm:^7.19.0, @babel/types@npm:^7.2.0, @babel/types@npm:^7.20.0, @babel/types@npm:^7.20.2, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": +"@babel/types@npm:^7.18.10, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.9, @babel/types@npm:^7.19.0, @babel/types@npm:^7.2.0, @babel/types@npm:^7.20.0, @babel/types@npm:^7.20.2, @babel/types@npm:^7.3.0, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": version: 7.20.2 resolution: "@babel/types@npm:7.20.2" dependencies: @@ -1414,6 +1392,20 @@ __metadata: languageName: node linkType: hard +"@esbuild/android-arm@npm:0.15.15": + version: 0.15.15 + resolution: "@esbuild/android-arm@npm:0.15.15" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@esbuild/linux-loong64@npm:0.15.15": + version: 0.15.15 + resolution: "@esbuild/linux-loong64@npm:0.15.15" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + "@eslint/eslintrc@npm:^1.3.3": version: 1.3.3 resolution: "@eslint/eslintrc@npm:1.3.3" @@ -1463,19 +1455,6 @@ __metadata: languageName: node linkType: hard -"@istanbuljs/load-nyc-config@npm:^1.0.0": - version: 1.1.0 - resolution: "@istanbuljs/load-nyc-config@npm:1.1.0" - dependencies: - camelcase: ^5.3.1 - find-up: ^4.1.0 - get-package-type: ^0.1.0 - js-yaml: ^3.13.1 - resolve-from: ^5.0.0 - checksum: d578da5e2e804d5c93228450a1380e1a3c691de4953acc162f387b717258512a3e07b83510a936d9fab03eac90817473917e24f5d16297af3867f59328d58568 - languageName: node - linkType: hard - "@istanbuljs/schema@npm:^0.1.2, @istanbuljs/schema@npm:^0.1.3": version: 0.1.3 resolution: "@istanbuljs/schema@npm:0.1.3" @@ -1483,155 +1462,6 @@ __metadata: languageName: node linkType: hard -"@jest/console@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/console@npm:29.3.1" - dependencies: - "@jest/types": ^29.3.1 - "@types/node": "*" - chalk: ^4.0.0 - jest-message-util: ^29.3.1 - jest-util: ^29.3.1 - slash: ^3.0.0 - checksum: 9eecbfb6df4f5b810374849b7566d321255e6fd6e804546236650384966be532ff75a3e445a3277eadefe67ddf4dc56cd38332abd72d6a450f1bea9866efc6d7 - languageName: node - linkType: hard - -"@jest/core@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/core@npm:29.3.1" - dependencies: - "@jest/console": ^29.3.1 - "@jest/reporters": ^29.3.1 - "@jest/test-result": ^29.3.1 - "@jest/transform": ^29.3.1 - "@jest/types": ^29.3.1 - "@types/node": "*" - ansi-escapes: ^4.2.1 - chalk: ^4.0.0 - ci-info: ^3.2.0 - exit: ^0.1.2 - graceful-fs: ^4.2.9 - jest-changed-files: ^29.2.0 - jest-config: ^29.3.1 - jest-haste-map: ^29.3.1 - jest-message-util: ^29.3.1 - jest-regex-util: ^29.2.0 - jest-resolve: ^29.3.1 - jest-resolve-dependencies: ^29.3.1 - jest-runner: ^29.3.1 - jest-runtime: ^29.3.1 - jest-snapshot: ^29.3.1 - jest-util: ^29.3.1 - jest-validate: ^29.3.1 - jest-watcher: ^29.3.1 - micromatch: ^4.0.4 - pretty-format: ^29.3.1 - slash: ^3.0.0 - strip-ansi: ^6.0.0 - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true - checksum: e3ac9201e8a084ccd832b17877b56490402b919f227622bb24f9372931e77b869e60959d34144222ce20fb619d0a6a6be20b257adb077a6b0f430a4584a45b0f - languageName: node - linkType: hard - -"@jest/environment@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/environment@npm:29.3.1" - dependencies: - "@jest/fake-timers": ^29.3.1 - "@jest/types": ^29.3.1 - "@types/node": "*" - jest-mock: ^29.3.1 - checksum: 974102aba7cc80508f787bb5504dcc96e5392e0a7776a63dffbf54ddc2c77d52ef4a3c08ed2eedec91965befff873f70cd7c9ed56f62bb132dcdb821730e6076 - languageName: node - linkType: hard - -"@jest/expect-utils@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/expect-utils@npm:29.3.1" - dependencies: - jest-get-type: ^29.2.0 - checksum: 7f3b853eb1e4299988f66b9aa49c1aacb7b8da1cf5518dca4ccd966e865947eed8f1bde6c8f5207d8400e9af870112a44b57aa83515ad6ea5e4a04a971863adb - languageName: node - linkType: hard - -"@jest/expect@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/expect@npm:29.3.1" - dependencies: - expect: ^29.3.1 - jest-snapshot: ^29.3.1 - checksum: 1d7b5cc735c8a99bfbed884d80fdb43b23b3456f4ec88c50fd86404b097bb77fba84f44e707fc9b49f106ca1154ae03f7c54dc34754b03f8a54eeb420196e5bf - languageName: node - linkType: hard - -"@jest/fake-timers@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/fake-timers@npm:29.3.1" - dependencies: - "@jest/types": ^29.3.1 - "@sinonjs/fake-timers": ^9.1.2 - "@types/node": "*" - jest-message-util: ^29.3.1 - jest-mock: ^29.3.1 - jest-util: ^29.3.1 - checksum: b1dafa8cdc439ef428cd772c775f0b22703677f52615513eda11a104bbfc352d7ec69b1225db95d4ef2e1b4ef0f23e1a7d96de5313aeb0950f672e6548ae069d - languageName: node - linkType: hard - -"@jest/globals@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/globals@npm:29.3.1" - dependencies: - "@jest/environment": ^29.3.1 - "@jest/expect": ^29.3.1 - "@jest/types": ^29.3.1 - jest-mock: ^29.3.1 - checksum: 4d2b9458aabf7c28fd167e53984477498c897b64eec67a7f84b8fff465235cae1456ee0721cb0e7943f0cda443c7656adb9801f9f34e27495b8ebbd9f3033100 - languageName: node - linkType: hard - -"@jest/reporters@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/reporters@npm:29.3.1" - dependencies: - "@bcoe/v8-coverage": ^0.2.3 - "@jest/console": ^29.3.1 - "@jest/test-result": ^29.3.1 - "@jest/transform": ^29.3.1 - "@jest/types": ^29.3.1 - "@jridgewell/trace-mapping": ^0.3.15 - "@types/node": "*" - chalk: ^4.0.0 - collect-v8-coverage: ^1.0.0 - exit: ^0.1.2 - glob: ^7.1.3 - graceful-fs: ^4.2.9 - istanbul-lib-coverage: ^3.0.0 - istanbul-lib-instrument: ^5.1.0 - istanbul-lib-report: ^3.0.0 - istanbul-lib-source-maps: ^4.0.0 - istanbul-reports: ^3.1.3 - jest-message-util: ^29.3.1 - jest-util: ^29.3.1 - jest-worker: ^29.3.1 - slash: ^3.0.0 - string-length: ^4.0.1 - strip-ansi: ^6.0.0 - v8-to-istanbul: ^9.0.1 - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true - checksum: 273e0c6953285f01151e9d84ac1e55744802a1ec79fb62dafeea16a49adfe7b24e7f35bef47a0214e5e057272dbfdacf594208286b7766046fd0f3cfa2043840 - languageName: node - linkType: hard - "@jest/schemas@npm:^29.0.0": version: 29.0.0 resolution: "@jest/schemas@npm:29.0.0" @@ -1641,64 +1471,6 @@ __metadata: languageName: node linkType: hard -"@jest/source-map@npm:^29.2.0": - version: 29.2.0 - resolution: "@jest/source-map@npm:29.2.0" - dependencies: - "@jridgewell/trace-mapping": ^0.3.15 - callsites: ^3.0.0 - graceful-fs: ^4.2.9 - checksum: 09f76ab63d15dcf44b3035a79412164f43be34ec189575930f1a00c87e36ea0211ebd6a4fbe2253c2516e19b49b131f348ddbb86223ca7b6bbac9a6bc76ec96e - languageName: node - linkType: hard - -"@jest/test-result@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/test-result@npm:29.3.1" - dependencies: - "@jest/console": ^29.3.1 - "@jest/types": ^29.3.1 - "@types/istanbul-lib-coverage": ^2.0.0 - collect-v8-coverage: ^1.0.0 - checksum: b24ac283321189b624c372a6369c0674b0ee6d9e3902c213452c6334d037113718156b315364bee8cee0f03419c2bdff5e2c63967193fb422830e79cbb26866a - languageName: node - linkType: hard - -"@jest/test-sequencer@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/test-sequencer@npm:29.3.1" - dependencies: - "@jest/test-result": ^29.3.1 - graceful-fs: ^4.2.9 - jest-haste-map: ^29.3.1 - slash: ^3.0.0 - checksum: a8325b1ea0ce644486fb63bb67cedd3524d04e3d7b1e6c1e3562bf12ef477ecd0cf34044391b2a07d925e1c0c8b4e0f3285035ceca3a474a2c55980f1708caf3 - languageName: node - linkType: hard - -"@jest/transform@npm:^29.3.1": - version: 29.3.1 - resolution: "@jest/transform@npm:29.3.1" - dependencies: - "@babel/core": ^7.11.6 - "@jest/types": ^29.3.1 - "@jridgewell/trace-mapping": ^0.3.15 - babel-plugin-istanbul: ^6.1.1 - chalk: ^4.0.0 - convert-source-map: ^2.0.0 - fast-json-stable-stringify: ^2.1.0 - graceful-fs: ^4.2.9 - jest-haste-map: ^29.3.1 - jest-regex-util: ^29.2.0 - jest-util: ^29.3.1 - micromatch: ^4.0.4 - pirates: ^4.0.4 - slash: ^3.0.0 - write-file-atomic: ^4.0.1 - checksum: 673df5900ffc95bc811084e09d6e47948034dea6ab6cc4f81f80977e3a52468a6c2284d0ba9796daf25a62ae50d12f7e97fc9a3a0c587f11f2a479ff5493ca53 - languageName: node - linkType: hard - "@jest/types@npm:^29.3.1": version: 29.3.1 resolution: "@jest/types@npm:29.3.1" @@ -1765,7 +1537,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/trace-mapping@npm:^0.3.12, @jridgewell/trace-mapping@npm:^0.3.14, @jridgewell/trace-mapping@npm:^0.3.15, @jridgewell/trace-mapping@npm:^0.3.9": +"@jridgewell/trace-mapping@npm:^0.3.12, @jridgewell/trace-mapping@npm:^0.3.14, @jridgewell/trace-mapping@npm:^0.3.9": version: 0.3.17 resolution: "@jridgewell/trace-mapping@npm:0.3.17" dependencies: @@ -1856,24 +1628,6 @@ __metadata: languageName: node linkType: hard -"@sinonjs/commons@npm:^1.7.0": - version: 1.8.5 - resolution: "@sinonjs/commons@npm:1.8.5" - dependencies: - type-detect: 4.0.8 - checksum: 74cb49e2f245dc0bfac990553dad0583884321f249522b3f73a6474ee9d7abe251814ebaab8094de7e94489d8efe415902fa67c47f637b751c121591b3cf5c39 - languageName: node - linkType: hard - -"@sinonjs/fake-timers@npm:^9.1.2": - version: 9.1.2 - resolution: "@sinonjs/fake-timers@npm:9.1.2" - dependencies: - "@sinonjs/commons": ^1.7.0 - checksum: 7d3aef54e17c1073101cb64d953157c19d62a40e261a30923fa1ee337b049c5f29cc47b1f0c477880f42b5659848ba9ab897607ac8ea4acd5c30ddcfac57fca6 - languageName: node - linkType: hard - "@tootallnate/once@npm:2": version: 2.0.0 resolution: "@tootallnate/once@npm:2.0.0" @@ -1888,39 +1642,7 @@ __metadata: languageName: node linkType: hard -"@types/babel__core@npm:^7.1.14": - version: 7.1.20 - resolution: "@types/babel__core@npm:7.1.20" - dependencies: - "@babel/parser": ^7.1.0 - "@babel/types": ^7.0.0 - "@types/babel__generator": "*" - "@types/babel__template": "*" - "@types/babel__traverse": "*" - checksum: a09c4f0456552547a5b8a5a009a3daec4d362f622168f8e08bda0ded2da0a65ab0b1642e23c433b3616721f5701dc34a996c5bde5baeaea53eda98f438043f2c - languageName: node - linkType: hard - -"@types/babel__generator@npm:*": - version: 7.6.4 - resolution: "@types/babel__generator@npm:7.6.4" - dependencies: - "@babel/types": ^7.0.0 - checksum: 20effbbb5f8a3a0211e95959d06ae70c097fb6191011b73b38fe86deebefad8e09ee014605e0fd3cdaedc73d158be555866810e9166e1f09e4cfd880b874dcb0 - languageName: node - linkType: hard - -"@types/babel__template@npm:*": - version: 7.4.1 - resolution: "@types/babel__template@npm:7.4.1" - dependencies: - "@babel/parser": ^7.1.0 - "@babel/types": ^7.0.0 - checksum: 649fe8b42c2876be1fd28c6ed9b276f78152d5904ec290b6c861d9ef324206e0a5c242e8305c421ac52ecf6358fa7e32ab7a692f55370484825c1df29b1596ee - languageName: node - linkType: hard - -"@types/babel__traverse@npm:*, @types/babel__traverse@npm:^7.0.6, @types/babel__traverse@npm:^7.18.0": +"@types/babel__traverse@npm:^7.18.0": version: 7.18.2 resolution: "@types/babel__traverse@npm:7.18.2" dependencies: @@ -1948,6 +1670,22 @@ __metadata: languageName: node linkType: hard +"@types/chai-subset@npm:^1.3.3": + version: 1.3.3 + resolution: "@types/chai-subset@npm:1.3.3" + dependencies: + "@types/chai": "*" + checksum: 4481da7345022995f5a105e6683744f7203d2c3d19cfe88d8e17274d045722948abf55e0adfd97709e0f043dade37a4d4e98cd4c660e2e8a14f23e6ecf79418f + languageName: node + linkType: hard + +"@types/chai@npm:*, @types/chai@npm:^4.3.3": + version: 4.3.4 + resolution: "@types/chai@npm:4.3.4" + checksum: 571184967beb03bf64c4392a13a7d44e72da9af5a1e83077ff81c39cf59c0fda2a5c78d2005084601cf8f3d11726608574d8b5b4a0e3e9736792807afd926cd0 + languageName: node + linkType: hard + "@types/connect-history-api-fallback@npm:^1.3.5": version: 1.3.5 resolution: "@types/connect-history-api-fallback@npm:1.3.5" @@ -2050,15 +1788,6 @@ __metadata: languageName: node linkType: hard -"@types/graceful-fs@npm:^4.1.3": - version: 4.1.5 - resolution: "@types/graceful-fs@npm:4.1.5" - dependencies: - "@types/node": "*" - checksum: d076bb61f45d0fc42dee496ef8b1c2f8742e15d5e47e90e20d0243386e426c04d4efd408a48875ab432f7960b4ce3414db20ed0fbbfc7bcc89d84e574f6e045a - languageName: node - linkType: hard - "@types/html-minifier-terser@npm:^6.0.0": version: 6.1.0 resolution: "@types/html-minifier-terser@npm:6.1.0" @@ -2100,16 +1829,6 @@ __metadata: languageName: node linkType: hard -"@types/jest@npm:29.2.3": - version: 29.2.3 - resolution: "@types/jest@npm:29.2.3" - dependencies: - expect: ^29.0.0 - pretty-format: ^29.0.0 - checksum: 55370906711b600a05b9e497c22aa74d80d8adcdbe4ac2f1bc9311f6f6ca0dd192862b6f38df6ac0d45e92396bcd796e377b1d8058c10bdfd584aeee580c3ce1 - languageName: node - linkType: hard - "@types/json-schema@npm:*, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9": version: 7.0.11 resolution: "@types/json-schema@npm:7.0.11" @@ -2138,13 +1857,6 @@ __metadata: languageName: node linkType: hard -"@types/prettier@npm:^2.1.5": - version: 2.7.1 - resolution: "@types/prettier@npm:2.7.1" - checksum: 5e3f58e229d6c73b5f5cae2e8f96c1c4a5b5805f83459e17a045ba8e96152b1d38e86b63e3172fb159dac923388699660862b75b2d37e54220805f0e691e26f1 - languageName: node - linkType: hard - "@types/qs@npm:*": version: 6.9.7 resolution: "@types/qs@npm:6.9.7" @@ -2218,13 +1930,6 @@ __metadata: languageName: node linkType: hard -"@types/stack-utils@npm:^2.0.0": - version: 2.0.1 - resolution: "@types/stack-utils@npm:2.0.1" - checksum: 205fdbe3326b7046d7eaf5e494d8084f2659086a266f3f9cf00bccc549c8e36e407f88168ad4383c8b07099957ad669f75f2532ed4bc70be2b037330f7bae019 - languageName: node - linkType: hard - "@types/ws@npm:^8.5.1": version: 8.5.3 resolution: "@types/ws@npm:8.5.3" @@ -2242,11 +1947,11 @@ __metadata: linkType: hard "@types/yargs@npm:^17.0.8": - version: 17.0.13 - resolution: "@types/yargs@npm:17.0.13" + version: 17.0.14 + resolution: "@types/yargs@npm:17.0.14" dependencies: "@types/yargs-parser": "*" - checksum: 0ab269abc2da2223cf0a8c16d578850fbe327d40fb85724b5c3f9f6cf38d03656ef699518c05d4df3bc337339ec6d0aad7df01682a9dca4783ad1ccc7336cf12 + checksum: 7c571560434e1295b31dfd7f8d3b4a88dbb8bfe8db0054cea35f829f86b1251f67e41eaa0cb5990f17e5ed9b1a508c686b2b9f15c3bafc467ba58989ac9223e8 languageName: node linkType: hard @@ -2370,6 +2075,16 @@ __metadata: languageName: node linkType: hard +"@vitest/coverage-c8@npm:0.25.3": + version: 0.25.3 + resolution: "@vitest/coverage-c8@npm:0.25.3" + dependencies: + c8: ^7.12.0 + vitest: 0.25.3 + checksum: 39d20990d56750e35c51aababe32a300cc30e6941442586d935e6f1f5ae29f4838bd5c7bcb70fc8cad19304dd1852bb6b5342e3367b1813dae79db99f201e768 + languageName: node + linkType: hard + "@webassemblyjs/ast@npm:1.11.1": version: 1.11.1 resolution: "@webassemblyjs/ast@npm:1.11.1" @@ -2603,6 +2318,13 @@ __metadata: languageName: node linkType: hard +"acorn-walk@npm:^8.2.0": + version: 8.2.0 + resolution: "acorn-walk@npm:8.2.0" + checksum: 1715e76c01dd7b2d4ca472f9c58968516a4899378a63ad5b6c2d668bba8da21a71976c14ec5f5b75f887b6317c4ae0b897ab141c831d741dc76024d8745f1ad1 + languageName: node + linkType: hard + "acorn@npm:^8.5.0, acorn@npm:^8.7.1, acorn@npm:^8.8.0": version: 8.8.1 resolution: "acorn@npm:8.8.1" @@ -2700,15 +2422,6 @@ __metadata: languageName: node linkType: hard -"ansi-escapes@npm:^4.2.1": - version: 4.3.2 - resolution: "ansi-escapes@npm:4.3.2" - dependencies: - type-fest: ^0.21.3 - checksum: 93111c42189c0a6bed9cdb4d7f2829548e943827ee8479c74d6e0b22ee127b2a21d3f8b5ca57723b8ef78ce011fbfc2784350eb2bde3ccfccf2f575fa8489815 - languageName: node - linkType: hard - "ansi-html-community@npm:^0.0.8": version: 0.0.8 resolution: "ansi-html-community@npm:0.0.8" @@ -2743,20 +2456,13 @@ __metadata: languageName: node linkType: hard -"ansi-styles@npm:^5.0.0": - version: 5.2.0 - resolution: "ansi-styles@npm:5.2.0" - checksum: d7f4e97ce0623aea6bc0d90dcd28881ee04cba06c570b97fd3391bd7a268eedfd9d5e2dd4fdcbdd82b8105df5faf6f24aaedc08eaf3da898e702db5948f63469 - languageName: node - linkType: hard - -"anymatch@npm:^3.0.3, anymatch@npm:~3.1.2": - version: 3.1.2 - resolution: "anymatch@npm:3.1.2" +"anymatch@npm:~3.1.2": + version: 3.1.3 + resolution: "anymatch@npm:3.1.3" dependencies: normalize-path: ^3.0.0 picomatch: ^2.0.4 - checksum: 985163db2292fac9e5a1e072bf99f1b5baccf196e4de25a0b0b81865ebddeb3b3eb4480734ef0a2ac8c002845396b91aa89121f5b84f93981a4658164a9ec6e9 + checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 languageName: node linkType: hard @@ -2777,15 +2483,6 @@ __metadata: languageName: node linkType: hard -"argparse@npm:^1.0.7": - version: 1.0.10 - resolution: "argparse@npm:1.0.10" - dependencies: - sprintf-js: ~1.0.2 - checksum: 7ca6e45583a28de7258e39e13d81e925cfa25d7d4aacbf806a382d3c02fcb13403a07fb8aeef949f10a7cfe4a62da0e2e807b348a5980554cc28ee573ef95945 - languageName: node - linkType: hard - "argparse@npm:^2.0.1": version: 2.0.1 resolution: "argparse@npm:2.0.1" @@ -2826,6 +2523,13 @@ __metadata: languageName: node linkType: hard +"assertion-error@npm:^1.1.0": + version: 1.1.0 + resolution: "assertion-error@npm:1.1.0" + checksum: fd9429d3a3d4fd61782eb3962ae76b6d08aa7383123fca0596020013b3ebd6647891a85b05ce821c47d1471ed1271f00b0545cf6a4326cf2fc91efcc3b0fbecf + languageName: node + linkType: hard + "ast-types@npm:0.12.4": version: 0.12.4 resolution: "ast-types@npm:0.12.4" @@ -2858,23 +2562,6 @@ __metadata: languageName: node linkType: hard -"babel-jest@npm:^29.3.1": - version: 29.3.1 - resolution: "babel-jest@npm:29.3.1" - dependencies: - "@jest/transform": ^29.3.1 - "@types/babel__core": ^7.1.14 - babel-plugin-istanbul: ^6.1.1 - babel-preset-jest: ^29.2.0 - chalk: ^4.0.0 - graceful-fs: ^4.2.9 - slash: ^3.0.0 - peerDependencies: - "@babel/core": ^7.8.0 - checksum: 793848238a771a931ddeb5930b9ec8ab800522ac8d64933665698f4a39603d157e572e20b57d79610277e1df88d3ee82b180d59a21f3570388f602beeb38a595 - languageName: node - linkType: hard - "babel-loader@npm:9.1.0": version: 9.1.0 resolution: "babel-loader@npm:9.1.0" @@ -2888,31 +2575,6 @@ __metadata: languageName: node linkType: hard -"babel-plugin-istanbul@npm:^6.1.1": - version: 6.1.1 - resolution: "babel-plugin-istanbul@npm:6.1.1" - dependencies: - "@babel/helper-plugin-utils": ^7.0.0 - "@istanbuljs/load-nyc-config": ^1.0.0 - "@istanbuljs/schema": ^0.1.2 - istanbul-lib-instrument: ^5.0.4 - test-exclude: ^6.0.0 - checksum: cb4fd95738219f232f0aece1116628cccff16db891713c4ccb501cddbbf9272951a5df81f2f2658dfdf4b3e7b236a9d5cbcf04d5d8c07dd5077297339598061a - languageName: node - linkType: hard - -"babel-plugin-jest-hoist@npm:^29.2.0": - version: 29.2.0 - resolution: "babel-plugin-jest-hoist@npm:29.2.0" - dependencies: - "@babel/template": ^7.3.3 - "@babel/types": ^7.3.3 - "@types/babel__core": ^7.1.14 - "@types/babel__traverse": ^7.0.6 - checksum: 368d271ceae491ae6b96cd691434859ea589fbe5fd5aead7660df75d02394077273c6442f61f390e9347adffab57a32b564d0fabcf1c53c4b83cd426cb644072 - languageName: node - linkType: hard - "babel-plugin-polyfill-corejs2@npm:^0.3.3": version: 0.3.3 resolution: "babel-plugin-polyfill-corejs2@npm:0.3.3" @@ -2949,40 +2611,6 @@ __metadata: languageName: node linkType: hard -"babel-preset-current-node-syntax@npm:^1.0.0": - version: 1.0.1 - resolution: "babel-preset-current-node-syntax@npm:1.0.1" - dependencies: - "@babel/plugin-syntax-async-generators": ^7.8.4 - "@babel/plugin-syntax-bigint": ^7.8.3 - "@babel/plugin-syntax-class-properties": ^7.8.3 - "@babel/plugin-syntax-import-meta": ^7.8.3 - "@babel/plugin-syntax-json-strings": ^7.8.3 - "@babel/plugin-syntax-logical-assignment-operators": ^7.8.3 - "@babel/plugin-syntax-nullish-coalescing-operator": ^7.8.3 - "@babel/plugin-syntax-numeric-separator": ^7.8.3 - "@babel/plugin-syntax-object-rest-spread": ^7.8.3 - "@babel/plugin-syntax-optional-catch-binding": ^7.8.3 - "@babel/plugin-syntax-optional-chaining": ^7.8.3 - "@babel/plugin-syntax-top-level-await": ^7.8.3 - peerDependencies: - "@babel/core": ^7.0.0 - checksum: d118c2742498c5492c095bc8541f4076b253e705b5f1ad9a2e7d302d81a84866f0070346662355c8e25fc02caa28dc2da8d69bcd67794a0d60c4d6fab6913cc8 - languageName: node - linkType: hard - -"babel-preset-jest@npm:^29.2.0": - version: 29.2.0 - resolution: "babel-preset-jest@npm:29.2.0" - dependencies: - babel-plugin-jest-hoist: ^29.2.0 - babel-preset-current-node-syntax: ^1.0.0 - peerDependencies: - "@babel/core": ^7.0.0 - checksum: 1b09a2db968c36e064daf98082cfffa39c849b63055112ddc56fc2551fd0d4783897265775b1d2f8a257960a3339745de92e74feb01bad86d41c4cecbfa854fc - languageName: node - linkType: hard - "balanced-match@npm:^1.0.0": version: 1.0.2 resolution: "balanced-match@npm:1.0.2" @@ -3115,28 +2743,10 @@ __metadata: languageName: node linkType: hard -"bs-logger@npm:0.x": - version: 0.2.6 - resolution: "bs-logger@npm:0.2.6" - dependencies: - fast-json-stable-stringify: 2.x - checksum: d34bdaf68c64bd099ab97c3ea608c9ae7d3f5faa1178b3f3f345acd94e852e608b2d4f9103fb2e503f5e69780e98293df41691b84be909b41cf5045374d54606 - languageName: node - linkType: hard - -"bser@npm:2.1.1": - version: 2.1.1 - resolution: "bser@npm:2.1.1" - dependencies: - node-int64: ^0.4.0 - checksum: 9ba4dc58ce86300c862bffc3ae91f00b2a03b01ee07f3564beeeaf82aa243b8b03ba53f123b0b842c190d4399b94697970c8e7cf7b1ea44b61aa28c3526a4449 - languageName: node - linkType: hard - -"buffer-from@npm:^1.0.0": - version: 1.1.2 - resolution: "buffer-from@npm:1.1.2" - checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb +"buffer-from@npm:^1.0.0": + version: 1.1.2 + resolution: "buffer-from@npm:1.1.2" + checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb languageName: node linkType: hard @@ -3164,7 +2774,7 @@ __metadata: languageName: node linkType: hard -"c8@npm:^7.6.0": +"c8@npm:^7.12.0, c8@npm:^7.6.0": version: 7.12.0 resolution: "c8@npm:7.12.0" dependencies: @@ -3239,20 +2849,6 @@ __metadata: languageName: node linkType: hard -"camelcase@npm:^5.3.1": - version: 5.3.1 - resolution: "camelcase@npm:5.3.1" - checksum: e6effce26b9404e3c0f301498184f243811c30dfe6d0b9051863bd8e4034d09c8c2923794f280d6827e5aa055f6c434115ff97864a16a963366fb35fd673024b - languageName: node - linkType: hard - -"camelcase@npm:^6.2.0": - version: 6.3.0 - resolution: "camelcase@npm:6.3.0" - checksum: 8c96818a9076434998511251dcb2761a94817ea17dbdc37f47ac080bd088fc62c7369429a19e2178b993497132c8cbcf5cc1f44ba963e76782ba469c0474938d - languageName: node - linkType: hard - "caniuse-api@npm:^3.0.0": version: 3.0.0 resolution: "caniuse-api@npm:3.0.0" @@ -3266,9 +2862,24 @@ __metadata: linkType: hard "caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001400": - version: 1.0.30001431 - resolution: "caniuse-lite@npm:1.0.30001431" - checksum: bc8ab55cd194e240152946b54bfaff7456180cc018674fc7ed134f4f502192405f6643f422feaa0a5e7cc02b5bac564cfac7771ac6d29f5d129482fcfe335ba1 + version: 1.0.30001434 + resolution: "caniuse-lite@npm:1.0.30001434" + checksum: 7c9d2641e8e8f3ddf9af14c4ce47266a9d8fd1fc0243626049ff1b2eca4bf02938ff440813cc3feae3fa8d851ec8d1b9718044340c8d09bb4372d92d4f6b519c + languageName: node + linkType: hard + +"chai@npm:^4.3.6": + version: 4.3.7 + resolution: "chai@npm:4.3.7" + dependencies: + assertion-error: ^1.1.0 + check-error: ^1.0.2 + deep-eql: ^4.1.2 + get-func-name: ^2.0.0 + loupe: ^2.3.1 + pathval: ^1.1.1 + type-detect: ^4.0.5 + checksum: 0bba7d267848015246a66995f044ce3f0ebc35e530da3cbdf171db744e14cbe301ab913a8d07caf7952b430257ccbb1a4a983c570a7c5748dc537897e5131f7c languageName: node linkType: hard @@ -3293,10 +2904,10 @@ __metadata: languageName: node linkType: hard -"char-regex@npm:^1.0.2": +"check-error@npm:^1.0.2": version: 1.0.2 - resolution: "char-regex@npm:1.0.2" - checksum: b563e4b6039b15213114626621e7a3d12f31008bdce20f9c741d69987f62aeaace7ec30f6018890ad77b2e9b4d95324c9f5acfca58a9441e3b1dcdd1e2525d17 + resolution: "check-error@npm:1.0.2" + checksum: d9d106504404b8addd1ee3f63f8c0eaa7cd962a1a28eb9c519b1c4a1dc7098be38007fc0060f045ee00f075fbb7a2a4f42abcf61d68323677e11ab98dc16042e languageName: node linkType: hard @@ -3334,16 +2945,9 @@ __metadata: linkType: hard "ci-info@npm:^3.2.0": - version: 3.6.1 - resolution: "ci-info@npm:3.6.1" - checksum: e463ed7152e795467c298268d58974d5e769fc7a0da2f72a53480042e01809e87908544b883a073391f446f46045b0d656c4a1fda3796c93740cd2be1c2d5f6f - languageName: node - linkType: hard - -"cjs-module-lexer@npm:^1.0.0": - version: 1.2.2 - resolution: "cjs-module-lexer@npm:1.2.2" - checksum: 977f3f042bd4f08e368c890d91eecfbc4f91da0bc009a3c557bc4dfbf32022ad1141244ac1178d44de70fc9f3dea7add7cd9a658a34b9fae98a55d8f92331ce5 + version: 3.7.0 + resolution: "ci-info@npm:3.7.0" + checksum: 6e5df0250382ff3732703b36b958d2d892dd3c481f9671666f96c2ab7888be744bc4dca81395be958dcb828502d94f18fa9aa8901c5a3c9923cda212df02724c languageName: node linkType: hard @@ -3392,17 +2996,6 @@ __metadata: languageName: node linkType: hard -"cliui@npm:^8.0.1": - version: 8.0.1 - resolution: "cliui@npm:8.0.1" - dependencies: - string-width: ^4.2.0 - strip-ansi: ^6.0.1 - wrap-ansi: ^7.0.0 - checksum: 79648b3b0045f2e285b76fb2e24e207c6db44323581e421c3acbd0e86454cba1b37aea976ab50195a49e7384b871e6dfb2247ad7dec53c02454ac6497394cb56 - languageName: node - linkType: hard - "clone-deep@npm:^4.0.1": version: 4.0.1 resolution: "clone-deep@npm:4.0.1" @@ -3414,13 +3007,6 @@ __metadata: languageName: node linkType: hard -"co@npm:^4.6.0": - version: 4.6.0 - resolution: "co@npm:4.6.0" - checksum: 5210d9223010eb95b29df06a91116f2cf7c8e0748a9013ed853b53f362ea0e822f1e5bb054fb3cefc645239a4cf966af1f6133a3b43f40d591f3b68ed6cf0510 - languageName: node - linkType: hard - "codemirror@npm:5.65.10": version: 5.65.10 resolution: "codemirror@npm:5.65.10" @@ -3428,13 +3014,6 @@ __metadata: languageName: node linkType: hard -"collect-v8-coverage@npm:^1.0.0": - version: 1.0.1 - resolution: "collect-v8-coverage@npm:1.0.1" - checksum: 4efe0a1fccd517b65478a2364b33dadd0a43fc92a56f59aaece9b6186fe5177b2de471253587de7c91516f07c7268c2f6770b6cbcffc0e0ece353b766ec87e55 - languageName: node - linkType: hard - "color-convert@npm:^1.9.0": version: 1.9.3 resolution: "color-convert@npm:1.9.3" @@ -3497,7 +3076,7 @@ __metadata: languageName: node linkType: hard -"commander@npm:9.4.1, commander@npm:^9.4.0, commander@npm:^9.4.1": +"commander@npm:9.4.1, commander@npm:^9.4.1": version: 9.4.1 resolution: "commander@npm:9.4.1" checksum: bfb18e325a5bdf772763c2213d5c7d9e77144d944124e988bcd8e5e65fb6d45d5d4e86b09155d0f2556c9a59c31e428720e57968bcd050b2306e910a0bf3cf13 @@ -3600,13 +3179,6 @@ __metadata: languageName: node linkType: hard -"convert-source-map@npm:^2.0.0": - version: 2.0.0 - resolution: "convert-source-map@npm:2.0.0" - checksum: 63ae9933be5a2b8d4509daca5124e20c14d023c820258e484e32dc324d34c2754e71297c94a05784064ad27615037ef677e3f0c00469fb55f409d2bb21261035 - languageName: node - linkType: hard - "cookie-signature@npm:1.0.6": version: 1.0.6 resolution: "cookie-signature@npm:1.0.6" @@ -3646,7 +3218,7 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:7.0.3, cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": +"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" dependencies: @@ -3859,10 +3431,12 @@ __metadata: languageName: node linkType: hard -"dedent@npm:^0.7.0": - version: 0.7.0 - resolution: "dedent@npm:0.7.0" - checksum: 87de191050d9a40dd70cad01159a0bcf05ecb59750951242070b6abf9569088684880d00ba92a955b4058804f16eeaf91d604f283929b4f614d181cd7ae633d2 +"deep-eql@npm:^4.1.2": + version: 4.1.2 + resolution: "deep-eql@npm:4.1.2" + dependencies: + type-detect: ^4.0.0 + checksum: 1832456c5f6a59d6ef6f0b925d4c75c30ef9582bc9a884c8c2475844d31febafefc5b3ff129cf95d14a3f450b7c1dfb52e597fad849653d8a123bbbb21d9fc3e languageName: node linkType: hard @@ -3873,13 +3447,6 @@ __metadata: languageName: node linkType: hard -"deepmerge@npm:^4.2.2": - version: 4.2.2 - resolution: "deepmerge@npm:4.2.2" - checksum: a8c43a1ed8d6d1ed2b5bf569fa4c8eb9f0924034baf75d5d406e47e157a451075c4db353efea7b6bcc56ec48116a8ce72fccf867b6e078e7c561904b5897530b - languageName: node - linkType: hard - "default-gateway@npm:^6.0.3": version: 6.0.3 resolution: "default-gateway@npm:6.0.3" @@ -3950,13 +3517,6 @@ __metadata: languageName: node linkType: hard -"detect-newline@npm:^3.0.0": - version: 3.1.0 - resolution: "detect-newline@npm:3.1.0" - checksum: ae6cd429c41ad01b164c59ea36f264a2c479598e61cba7c99da24175a7ab80ddf066420f2bec9a1c57a6bead411b4655ff15ad7d281c000a89791f48cbe939e7 - languageName: node - linkType: hard - "detect-node@npm:^2.0.4": version: 2.1.0 resolution: "detect-node@npm:2.1.0" @@ -3964,13 +3524,6 @@ __metadata: languageName: node linkType: hard -"diff-sequences@npm:^29.3.1": - version: 29.3.1 - resolution: "diff-sequences@npm:29.3.1" - checksum: 8edab8c383355022e470779a099852d595dd856f9f5bd7af24f177e74138a668932268b4c4fd54096eed643861575c3652d4ecbbb1a9d710488286aed3ffa443 - languageName: node - linkType: hard - "dir-glob@npm:^3.0.1": version: 3.0.1 resolution: "dir-glob@npm:3.0.1" @@ -4076,13 +3629,6 @@ __metadata: languageName: node linkType: hard -"emittery@npm:^0.13.1": - version: 0.13.1 - resolution: "emittery@npm:0.13.1" - checksum: 2b089ab6306f38feaabf4f6f02792f9ec85fc054fda79f44f6790e61bbf6bc4e1616afb9b232e0c5ec5289a8a452f79bfa6d905a6fd64e94b49981f0934001c6 - languageName: node - linkType: hard - "emoji-regex@npm:^8.0.0": version: 8.0.0 resolution: "emoji-regex@npm:8.0.0" @@ -4107,12 +3653,12 @@ __metadata: linkType: hard "enhanced-resolve@npm:^5.10.0": - version: 5.10.0 - resolution: "enhanced-resolve@npm:5.10.0" + version: 5.12.0 + resolution: "enhanced-resolve@npm:5.12.0" dependencies: graceful-fs: ^4.2.4 tapable: ^2.2.0 - checksum: 0bb9830704db271610f900e8d79d70a740ea16f251263362b0c91af545576d09fe50103496606c1300a05e588372d6f9780a9bc2e30ce8ef9b827ec8f44687ff + checksum: bf3f787facaf4ce3439bef59d148646344e372bef5557f0d37ea8aa02c51f50a925cd1f07b8d338f18992c29f544ec235a8c64bcdb56030196c48832a5494174 languageName: node linkType: hard @@ -4123,7 +3669,7 @@ __metadata: languageName: node linkType: hard -"entities@npm:^4.3.1, entities@npm:^4.4.0": +"entities@npm:^4.4.0": version: 4.4.0 resolution: "entities@npm:4.4.0" checksum: 84d250329f4b56b40fa93ed067b194db21e8815e4eb9b59f43a086f0ecd342814f6bc483de8a77da5d64e0f626033192b1b4f1792232a7ea6b970ebe0f3187c2 @@ -4164,15 +3710,6 @@ __metadata: languageName: node linkType: hard -"error-ex@npm:^1.3.1": - version: 1.3.2 - resolution: "error-ex@npm:1.3.2" - dependencies: - is-arrayish: ^0.2.1 - checksum: c1c2b8b65f9c91b0f9d75f0debaa7ec5b35c266c2cac5de412c1a6de86d4cbae04ae44e510378cb14d032d0645a36925d0186f8bb7367bcc629db256b743a001 - languageName: node - linkType: hard - "es-module-lexer@npm:^0.9.0": version: 0.9.3 resolution: "es-module-lexer@npm:0.9.3" @@ -4187,6 +3724,223 @@ __metadata: languageName: node linkType: hard +"esbuild-android-64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-android-64@npm:0.15.15" + conditions: os=android & cpu=x64 + languageName: node + linkType: hard + +"esbuild-android-arm64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-android-arm64@npm:0.15.15" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"esbuild-darwin-64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-darwin-64@npm:0.15.15" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"esbuild-darwin-arm64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-darwin-arm64@npm:0.15.15" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"esbuild-freebsd-64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-freebsd-64@npm:0.15.15" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"esbuild-freebsd-arm64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-freebsd-arm64@npm:0.15.15" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"esbuild-linux-32@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-linux-32@npm:0.15.15" + conditions: os=linux & cpu=ia32 + languageName: node + linkType: hard + +"esbuild-linux-64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-linux-64@npm:0.15.15" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"esbuild-linux-arm64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-linux-arm64@npm:0.15.15" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"esbuild-linux-arm@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-linux-arm@npm:0.15.15" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"esbuild-linux-mips64le@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-linux-mips64le@npm:0.15.15" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + +"esbuild-linux-ppc64le@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-linux-ppc64le@npm:0.15.15" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + +"esbuild-linux-riscv64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-linux-riscv64@npm:0.15.15" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + +"esbuild-linux-s390x@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-linux-s390x@npm:0.15.15" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + +"esbuild-netbsd-64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-netbsd-64@npm:0.15.15" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"esbuild-openbsd-64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-openbsd-64@npm:0.15.15" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + +"esbuild-sunos-64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-sunos-64@npm:0.15.15" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + +"esbuild-windows-32@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-windows-32@npm:0.15.15" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"esbuild-windows-64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-windows-64@npm:0.15.15" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + +"esbuild-windows-arm64@npm:0.15.15": + version: 0.15.15 + resolution: "esbuild-windows-arm64@npm:0.15.15" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"esbuild@npm:^0.15.9": + version: 0.15.15 + resolution: "esbuild@npm:0.15.15" + dependencies: + "@esbuild/android-arm": 0.15.15 + "@esbuild/linux-loong64": 0.15.15 + esbuild-android-64: 0.15.15 + esbuild-android-arm64: 0.15.15 + esbuild-darwin-64: 0.15.15 + esbuild-darwin-arm64: 0.15.15 + esbuild-freebsd-64: 0.15.15 + esbuild-freebsd-arm64: 0.15.15 + esbuild-linux-32: 0.15.15 + esbuild-linux-64: 0.15.15 + esbuild-linux-arm: 0.15.15 + esbuild-linux-arm64: 0.15.15 + esbuild-linux-mips64le: 0.15.15 + esbuild-linux-ppc64le: 0.15.15 + esbuild-linux-riscv64: 0.15.15 + esbuild-linux-s390x: 0.15.15 + esbuild-netbsd-64: 0.15.15 + esbuild-openbsd-64: 0.15.15 + esbuild-sunos-64: 0.15.15 + esbuild-windows-32: 0.15.15 + esbuild-windows-64: 0.15.15 + esbuild-windows-arm64: 0.15.15 + dependenciesMeta: + "@esbuild/android-arm": + optional: true + "@esbuild/linux-loong64": + optional: true + esbuild-android-64: + optional: true + esbuild-android-arm64: + optional: true + esbuild-darwin-64: + optional: true + esbuild-darwin-arm64: + optional: true + esbuild-freebsd-64: + optional: true + esbuild-freebsd-arm64: + optional: true + esbuild-linux-32: + optional: true + esbuild-linux-64: + optional: true + esbuild-linux-arm: + optional: true + esbuild-linux-arm64: + optional: true + esbuild-linux-mips64le: + optional: true + esbuild-linux-ppc64le: + optional: true + esbuild-linux-riscv64: + optional: true + esbuild-linux-s390x: + optional: true + esbuild-netbsd-64: + optional: true + esbuild-openbsd-64: + optional: true + esbuild-sunos-64: + optional: true + esbuild-windows-32: + optional: true + esbuild-windows-64: + optional: true + esbuild-windows-arm64: + optional: true + bin: + esbuild: bin/esbuild + checksum: 9a194a310ac7d6989d1fe7354901d531d3b0d4cc1897a85a7cb9f1ae0fe8d82eb59747e63c91f676bab7bed8d6a1f28f620d49f043e7bd6203f9afe34031f739 + languageName: node + linkType: hard + "escalade@npm:^3.1.1": version: 3.1.1 resolution: "escalade@npm:3.1.1" @@ -4208,13 +3962,6 @@ __metadata: languageName: node linkType: hard -"escape-string-regexp@npm:^2.0.0": - version: 2.0.0 - resolution: "escape-string-regexp@npm:2.0.0" - checksum: 9f8a2d5743677c16e85c810e3024d54f0c8dea6424fad3c79ef6666e81dd0846f7437f5e729dfcdac8981bc9e5294c39b4580814d114076b8d36318f46ae4395 - languageName: node - linkType: hard - "escape-string-regexp@npm:^4.0.0": version: 4.0.0 resolution: "escape-string-regexp@npm:4.0.0" @@ -4353,7 +4100,7 @@ __metadata: languageName: node linkType: hard -"esprima@npm:^4.0.0, esprima@npm:~4.0.0": +"esprima@npm:~4.0.0": version: 4.0.1 resolution: "esprima@npm:4.0.1" bin: @@ -4451,26 +4198,6 @@ __metadata: languageName: node linkType: hard -"exit@npm:^0.1.2": - version: 0.1.2 - resolution: "exit@npm:0.1.2" - checksum: abc407f07a875c3961e4781dfcb743b58d6c93de9ab263f4f8c9d23bb6da5f9b7764fc773f86b43dd88030444d5ab8abcb611cb680fba8ca075362b77114bba3 - languageName: node - linkType: hard - -"expect@npm:^29.0.0, expect@npm:^29.3.1": - version: 29.3.1 - resolution: "expect@npm:29.3.1" - dependencies: - "@jest/expect-utils": ^29.3.1 - jest-get-type: ^29.2.0 - jest-matcher-utils: ^29.3.1 - jest-message-util: ^29.3.1 - jest-util: ^29.3.1 - checksum: e9588c2a430b558b9a3dc72d4ad05f36b047cb477bc6a7bb9cfeef7614fe7e5edbab424c2c0ce82739ee21ecbbbd24596259528209f84cd72500cc612d910d30 - languageName: node - linkType: hard - "express@npm:^4.17.3": version: 4.18.2 resolution: "express@npm:4.18.2" @@ -4537,7 +4264,7 @@ __metadata: languageName: node linkType: hard -"fast-json-stable-stringify@npm:2.x, fast-json-stable-stringify@npm:^2.0.0, fast-json-stable-stringify@npm:^2.1.0": +"fast-json-stable-stringify@npm:^2.0.0": version: 2.1.0 resolution: "fast-json-stable-stringify@npm:2.1.0" checksum: b191531e36c607977e5b1c47811158733c34ccb3bfde92c44798929e9b4154884378536d26ad90dfecd32e1ffc09c545d23535ad91b3161a27ddbb8ebe0cbecb @@ -4576,15 +4303,6 @@ __metadata: languageName: node linkType: hard -"fb-watchman@npm:^2.0.0": - version: 2.0.2 - resolution: "fb-watchman@npm:2.0.2" - dependencies: - bser: 2.1.1 - checksum: b15a124cef28916fe07b400eb87cbc73ca082c142abf7ca8e8de6af43eca79ca7bd13eb4d4d48240b3bd3136eaac40d16e42d6edf87a8e5d1dd8070626860c78 - languageName: node - linkType: hard - "file-entry-cache@npm:^6.0.1": version: 6.0.1 resolution: "file-entry-cache@npm:6.0.1" @@ -4629,7 +4347,7 @@ __metadata: languageName: node linkType: hard -"find-up@npm:^4.0.0, find-up@npm:^4.1.0": +"find-up@npm:^4.0.0": version: 4.1.0 resolution: "find-up@npm:4.1.0" dependencies: @@ -4732,7 +4450,7 @@ __metadata: languageName: node linkType: hard -"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2": +"fsevents@npm:~2.3.2": version: 2.3.2 resolution: "fsevents@npm:2.3.2" dependencies: @@ -4742,7 +4460,7 @@ __metadata: languageName: node linkType: hard -"fsevents@patch:fsevents@^2.3.2#~builtin, fsevents@patch:fsevents@~2.3.2#~builtin": +"fsevents@patch:fsevents@~2.3.2#~builtin": version: 2.3.2 resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" dependencies: @@ -4788,6 +4506,13 @@ __metadata: languageName: node linkType: hard +"get-func-name@npm:^2.0.0": + version: 2.0.0 + resolution: "get-func-name@npm:2.0.0" + checksum: 8d82e69f3e7fab9e27c547945dfe5cc0c57fc0adf08ce135dddb01081d75684a03e7a0487466f478872b341d52ac763ae49e660d01ab83741f74932085f693c3 + languageName: node + linkType: hard + "get-intrinsic@npm:^1.0.2, get-intrinsic@npm:^1.1.1, get-intrinsic@npm:^1.1.3": version: 1.1.3 resolution: "get-intrinsic@npm:1.1.3" @@ -4799,13 +4524,6 @@ __metadata: languageName: node linkType: hard -"get-package-type@npm:^0.1.0": - version: 0.1.0 - resolution: "get-package-type@npm:0.1.0" - checksum: bba0811116d11e56d702682ddef7c73ba3481f114590e705fc549f4d868972263896af313c57a25c076e3c0d567e11d919a64ba1b30c879be985fc9d44f96148 - languageName: node - linkType: hard - "get-stream@npm:^6.0.0": version: 6.0.1 resolution: "get-stream@npm:6.0.1" @@ -5045,19 +4763,19 @@ __metadata: linkType: hard "html-minifier-terser@npm:^7.0.0": - version: 7.0.0 - resolution: "html-minifier-terser@npm:7.0.0" + version: 7.1.0 + resolution: "html-minifier-terser@npm:7.1.0" dependencies: camel-case: ^4.1.2 clean-css: 5.2.0 - commander: ^9.4.0 - entities: ^4.3.1 + commander: ^9.4.1 + entities: ^4.4.0 param-case: ^3.0.4 relateurl: ^0.2.7 - terser: ^5.14.2 + terser: ^5.15.1 bin: html-minifier-terser: cli.js - checksum: eabd3b4835d9663bf7c30ea0f1c57870b0d8f7dc27b9fa17852ea57bfdd5fdc0ed9b7b83a7f13edd8626ccf98d3082e347764754278a661cab291469fd37dced + checksum: 351de28d85f142314a6a9b5222bdcaf068cef6bf2f521952ef55d99a6acdcecd0b4dbc42578da2d438d579c6e868b899ca19eac901ee6f9f0c69c223b5942099 languageName: node linkType: hard @@ -5355,13 +5073,6 @@ __metadata: languageName: node linkType: hard -"is-arrayish@npm:^0.2.1": - version: 0.2.1 - resolution: "is-arrayish@npm:0.2.1" - checksum: eef4417e3c10e60e2c810b6084942b3ead455af16c4509959a27e490e7aee87cfb3f38e01bbde92220b528a0ee1a18d52b787e1458ee86174d8c7f0e58cd488f - languageName: node - linkType: hard - "is-binary-path@npm:~2.1.0": version: 2.1.0 resolution: "is-binary-path@npm:2.1.0" @@ -5410,13 +5121,6 @@ __metadata: languageName: node linkType: hard -"is-generator-fn@npm:^2.0.0": - version: 2.1.0 - resolution: "is-generator-fn@npm:2.1.0" - checksum: a6ad5492cf9d1746f73b6744e0c43c0020510b59d56ddcb78a91cbc173f09b5e6beff53d75c9c5a29feb618bfef2bf458e025ecf3a57ad2268e2fb2569f56215 - languageName: node - linkType: hard - "is-generator-function@npm:^1.0.7": version: 1.0.10 resolution: "is-generator-function@npm:1.0.10" @@ -5546,466 +5250,45 @@ __metadata: languageName: node linkType: hard -"istanbul-lib-coverage@npm:^3.0.0, istanbul-lib-coverage@npm:^3.2.0": - version: 3.2.0 - resolution: "istanbul-lib-coverage@npm:3.2.0" - checksum: a2a545033b9d56da04a8571ed05c8120bf10e9bce01cf8633a3a2b0d1d83dff4ac4fe78d6d5673c27fc29b7f21a41d75f83a36be09f82a61c367b56aa73c1ff9 - languageName: node - linkType: hard - -"istanbul-lib-instrument@npm:^5.0.4, istanbul-lib-instrument@npm:^5.1.0": - version: 5.2.1 - resolution: "istanbul-lib-instrument@npm:5.2.1" - dependencies: - "@babel/core": ^7.12.3 - "@babel/parser": ^7.14.7 - "@istanbuljs/schema": ^0.1.2 - istanbul-lib-coverage: ^3.2.0 - semver: ^6.3.0 - checksum: bf16f1803ba5e51b28bbd49ed955a736488381e09375d830e42ddeb403855b2006f850711d95ad726f2ba3f1ae8e7366de7e51d2b9ac67dc4d80191ef7ddf272 - languageName: node - linkType: hard - -"istanbul-lib-report@npm:^3.0.0": - version: 3.0.0 - resolution: "istanbul-lib-report@npm:3.0.0" - dependencies: - istanbul-lib-coverage: ^3.0.0 - make-dir: ^3.0.0 - supports-color: ^7.1.0 - checksum: 3f29eb3f53c59b987386e07fe772d24c7f58c6897f34c9d7a296f4000de7ae3de9eb95c3de3df91dc65b134c84dee35c54eee572a56243e8907c48064e34ff1b - languageName: node - linkType: hard - -"istanbul-lib-source-maps@npm:^4.0.0": - version: 4.0.1 - resolution: "istanbul-lib-source-maps@npm:4.0.1" - dependencies: - debug: ^4.1.1 - istanbul-lib-coverage: ^3.0.0 - source-map: ^0.6.1 - checksum: 21ad3df45db4b81852b662b8d4161f6446cd250c1ddc70ef96a585e2e85c26ed7cd9c2a396a71533cfb981d1a645508bc9618cae431e55d01a0628e7dec62ef2 - languageName: node - linkType: hard - -"istanbul-reports@npm:^3.1.3, istanbul-reports@npm:^3.1.4": - version: 3.1.5 - resolution: "istanbul-reports@npm:3.1.5" - dependencies: - html-escaper: ^2.0.0 - istanbul-lib-report: ^3.0.0 - checksum: 7867228f83ed39477b188ea07e7ccb9b4f5320b6f73d1db93a0981b7414fa4ef72d3f80c4692c442f90fc250d9406e71d8d7ab65bb615cb334e6292b73192b89 - languageName: node - linkType: hard - -"jest-changed-files@npm:^29.2.0": - version: 29.2.0 - resolution: "jest-changed-files@npm:29.2.0" - dependencies: - execa: ^5.0.0 - p-limit: ^3.1.0 - checksum: 8ad8290324db1de2ee3c9443d3e3fbfdcb6d72ec7054c5796be2854b2bc239dea38a7c797c8c9c2bd959f539d44305790f2f75b18f3046b04317ed77c7480cb1 - languageName: node - linkType: hard - -"jest-circus@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-circus@npm:29.3.1" - dependencies: - "@jest/environment": ^29.3.1 - "@jest/expect": ^29.3.1 - "@jest/test-result": ^29.3.1 - "@jest/types": ^29.3.1 - "@types/node": "*" - chalk: ^4.0.0 - co: ^4.6.0 - dedent: ^0.7.0 - is-generator-fn: ^2.0.0 - jest-each: ^29.3.1 - jest-matcher-utils: ^29.3.1 - jest-message-util: ^29.3.1 - jest-runtime: ^29.3.1 - jest-snapshot: ^29.3.1 - jest-util: ^29.3.1 - p-limit: ^3.1.0 - pretty-format: ^29.3.1 - slash: ^3.0.0 - stack-utils: ^2.0.3 - checksum: 125710debd998ad9693893e7c1235e271b79f104033b8169d82afe0bc0d883f8f5245feef87adcbb22ad27ff749fd001aa998d11a132774b03b4e2b8af77d5d8 - languageName: node - linkType: hard - -"jest-cli@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-cli@npm:29.3.1" - dependencies: - "@jest/core": ^29.3.1 - "@jest/test-result": ^29.3.1 - "@jest/types": ^29.3.1 - chalk: ^4.0.0 - exit: ^0.1.2 - graceful-fs: ^4.2.9 - import-local: ^3.0.2 - jest-config: ^29.3.1 - jest-util: ^29.3.1 - jest-validate: ^29.3.1 - prompts: ^2.0.1 - yargs: ^17.3.1 - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true - bin: - jest: bin/jest.js - checksum: 829895d33060042443bd1e9e87eb68993773d74f2c8a9b863acf53cece39d227ae0e7d76df2e9c5934c414bdf70ce398a34b3122cfe22164acb2499a74d7288d - languageName: node - linkType: hard - -"jest-config@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-config@npm:29.3.1" - dependencies: - "@babel/core": ^7.11.6 - "@jest/test-sequencer": ^29.3.1 - "@jest/types": ^29.3.1 - babel-jest: ^29.3.1 - chalk: ^4.0.0 - ci-info: ^3.2.0 - deepmerge: ^4.2.2 - glob: ^7.1.3 - graceful-fs: ^4.2.9 - jest-circus: ^29.3.1 - jest-environment-node: ^29.3.1 - jest-get-type: ^29.2.0 - jest-regex-util: ^29.2.0 - jest-resolve: ^29.3.1 - jest-runner: ^29.3.1 - jest-util: ^29.3.1 - jest-validate: ^29.3.1 - micromatch: ^4.0.4 - parse-json: ^5.2.0 - pretty-format: ^29.3.1 - slash: ^3.0.0 - strip-json-comments: ^3.1.1 - peerDependencies: - "@types/node": "*" - ts-node: ">=9.0.0" - peerDependenciesMeta: - "@types/node": - optional: true - ts-node: - optional: true - checksum: 6e663f04ae1024a53a4c2c744499b4408ca9a8b74381dd5e31b11bb3c7393311ecff0fb61b06287768709eb2c9e5a2fd166d258f5a9123abbb4c5812f99c12fe - languageName: node - linkType: hard - -"jest-diff@npm:29.3.1, jest-diff@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-diff@npm:29.3.1" - dependencies: - chalk: ^4.0.0 - diff-sequences: ^29.3.1 - jest-get-type: ^29.2.0 - pretty-format: ^29.3.1 - checksum: ac5c09745f2b1897e6f53216acaf6ed44fc4faed8e8df053ff4ac3db5d2a1d06a17b876e49faaa15c8a7a26f5671bcbed0a93781dcc2835f781c79a716a591a9 - languageName: node - linkType: hard - -"jest-docblock@npm:^29.2.0": - version: 29.2.0 - resolution: "jest-docblock@npm:29.2.0" - dependencies: - detect-newline: ^3.0.0 - checksum: b3f1227b7d73fc9e4952180303475cf337b36fa65c7f730ac92f0580f1c08439983262fee21cf3dba11429aa251b4eee1e3bc74796c5777116b400d78f9d2bbe - languageName: node - linkType: hard - -"jest-each@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-each@npm:29.3.1" - dependencies: - "@jest/types": ^29.3.1 - chalk: ^4.0.0 - jest-get-type: ^29.2.0 - jest-util: ^29.3.1 - pretty-format: ^29.3.1 - checksum: 16d51ef8f96fba44a3479f1c6f7672027e3b39236dc4e41217c38fe60a3b66b022ffcee72f8835a442f7a8a0a65980a93fb8e73a9782d192452526e442ad049a - languageName: node - linkType: hard - -"jest-environment-node@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-environment-node@npm:29.3.1" - dependencies: - "@jest/environment": ^29.3.1 - "@jest/fake-timers": ^29.3.1 - "@jest/types": ^29.3.1 - "@types/node": "*" - jest-mock: ^29.3.1 - jest-util: ^29.3.1 - checksum: 16d4854bd2d35501bd4862ca069baf27ce9f5fd7642fdcab9d2dab49acd28c082d0c8882bf2bb28ed7bbaada486da577c814c9688ddc62d1d9f74a954fde996a - languageName: node - linkType: hard - -"jest-get-type@npm:^29.2.0": - version: 29.2.0 - resolution: "jest-get-type@npm:29.2.0" - checksum: e396fd880a30d08940ed8a8e43cd4595db1b8ff09649018eb358ca701811137556bae82626af73459e3c0f8c5e972ed1e57fd3b1537b13a260893dac60a90942 - languageName: node - linkType: hard - -"jest-haste-map@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-haste-map@npm:29.3.1" - dependencies: - "@jest/types": ^29.3.1 - "@types/graceful-fs": ^4.1.3 - "@types/node": "*" - anymatch: ^3.0.3 - fb-watchman: ^2.0.0 - fsevents: ^2.3.2 - graceful-fs: ^4.2.9 - jest-regex-util: ^29.2.0 - jest-util: ^29.3.1 - jest-worker: ^29.3.1 - micromatch: ^4.0.4 - walker: ^1.0.8 - dependenciesMeta: - fsevents: - optional: true - checksum: 97ea26af0c28a2ba568c9c65d06211487bbcd501cb4944f9d55e07fd2b00ad96653ea2cc9033f3d5b7dc1feda33e47ae9cc56b400191ea4533be213c9f82e67c - languageName: node - linkType: hard - -"jest-leak-detector@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-leak-detector@npm:29.3.1" - dependencies: - jest-get-type: ^29.2.0 - pretty-format: ^29.3.1 - checksum: 0dd8ed31ae0b5a3d14f13f567ca8567f2663dd2d540d1e55511d3b3fd7f80a1d075392179674ebe9fab9be0b73678bf4d2f8bbbc0f4bdd52b9815259194da559 - languageName: node - linkType: hard - -"jest-matcher-utils@npm:29.3.1, jest-matcher-utils@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-matcher-utils@npm:29.3.1" - dependencies: - chalk: ^4.0.0 - jest-diff: ^29.3.1 - jest-get-type: ^29.2.0 - pretty-format: ^29.3.1 - checksum: 311e8d9f1e935216afc7dd8c6acf1fbda67a7415e1afb1bf72757213dfb025c1f2dc5e2c185c08064a35cdc1f2d8e40c57616666774ed1b03e57eb311c20ec77 - languageName: node - linkType: hard - -"jest-message-util@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-message-util@npm:29.3.1" - dependencies: - "@babel/code-frame": ^7.12.13 - "@jest/types": ^29.3.1 - "@types/stack-utils": ^2.0.0 - chalk: ^4.0.0 - graceful-fs: ^4.2.9 - micromatch: ^4.0.4 - pretty-format: ^29.3.1 - slash: ^3.0.0 - stack-utils: ^2.0.3 - checksum: 15d0a2fca3919eb4570bbf575734780c4b9e22de6aae903c4531b346699f7deba834c6c86fe6e9a83ad17fac0f7935511cf16dce4d71a93a71ebb25f18a6e07b - languageName: node - linkType: hard - -"jest-mock@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-mock@npm:29.3.1" - dependencies: - "@jest/types": ^29.3.1 - "@types/node": "*" - jest-util: ^29.3.1 - checksum: 9098852cb2866db4a1a59f9f7581741dfc572f648e9e574a1b187fd69f5f2f6190ad387ede21e139a8b80a6a1343ecc3d6751cd2ae1ae11d7ea9fa1950390fb2 - languageName: node - linkType: hard - -"jest-pnp-resolver@npm:^1.2.2": - version: 1.2.3 - resolution: "jest-pnp-resolver@npm:1.2.3" - peerDependencies: - jest-resolve: "*" - peerDependenciesMeta: - jest-resolve: - optional: true - checksum: db1a8ab2cb97ca19c01b1cfa9a9c8c69a143fde833c14df1fab0766f411b1148ff0df878adea09007ac6a2085ec116ba9a996a6ad104b1e58c20adbf88eed9b2 - languageName: node - linkType: hard - -"jest-regex-util@npm:^29.2.0": - version: 29.2.0 - resolution: "jest-regex-util@npm:29.2.0" - checksum: 7c533e51c51230dac20c0d7395b19b8366cb022f7c6e08e6bcf2921626840ff90424af4c9b4689f02f0addfc9b071c4cd5f8f7a989298a4c8e0f9c94418ca1c3 - languageName: node - linkType: hard - -"jest-resolve-dependencies@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-resolve-dependencies@npm:29.3.1" - dependencies: - jest-regex-util: ^29.2.0 - jest-snapshot: ^29.3.1 - checksum: 6ec4727a87c6e7954e93de9949ab9967b340ee2f07626144c273355f05a2b65fa47eb8dece2d6e5f4fd99cdb893510a3540aa5e14ba443f70b3feb63f6f98982 - languageName: node - linkType: hard - -"jest-resolve@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-resolve@npm:29.3.1" - dependencies: - chalk: ^4.0.0 - graceful-fs: ^4.2.9 - jest-haste-map: ^29.3.1 - jest-pnp-resolver: ^1.2.2 - jest-util: ^29.3.1 - jest-validate: ^29.3.1 - resolve: ^1.20.0 - resolve.exports: ^1.1.0 - slash: ^3.0.0 - checksum: 0dea22ed625e07b8bfee52dea1391d3a4b453c1a0c627a0fa7c22e44bb48e1c289afe6f3c316def70753773f099c4e8f436c7a2cc12fcc6c7dd6da38cba2cd5f - languageName: node - linkType: hard - -"jest-runner@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-runner@npm:29.3.1" - dependencies: - "@jest/console": ^29.3.1 - "@jest/environment": ^29.3.1 - "@jest/test-result": ^29.3.1 - "@jest/transform": ^29.3.1 - "@jest/types": ^29.3.1 - "@types/node": "*" - chalk: ^4.0.0 - emittery: ^0.13.1 - graceful-fs: ^4.2.9 - jest-docblock: ^29.2.0 - jest-environment-node: ^29.3.1 - jest-haste-map: ^29.3.1 - jest-leak-detector: ^29.3.1 - jest-message-util: ^29.3.1 - jest-resolve: ^29.3.1 - jest-runtime: ^29.3.1 - jest-util: ^29.3.1 - jest-watcher: ^29.3.1 - jest-worker: ^29.3.1 - p-limit: ^3.1.0 - source-map-support: 0.5.13 - checksum: 61ad445d8a5f29573332f27a21fc942fb0d2a82bf901a0ea1035bf3bd7f349d1e425f71f54c3a3f89b292a54872c3248d395a2829d987f26b6025b15530ea5d2 - languageName: node - linkType: hard - -"jest-runtime@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-runtime@npm:29.3.1" - dependencies: - "@jest/environment": ^29.3.1 - "@jest/fake-timers": ^29.3.1 - "@jest/globals": ^29.3.1 - "@jest/source-map": ^29.2.0 - "@jest/test-result": ^29.3.1 - "@jest/transform": ^29.3.1 - "@jest/types": ^29.3.1 - "@types/node": "*" - chalk: ^4.0.0 - cjs-module-lexer: ^1.0.0 - collect-v8-coverage: ^1.0.0 - glob: ^7.1.3 - graceful-fs: ^4.2.9 - jest-haste-map: ^29.3.1 - jest-message-util: ^29.3.1 - jest-mock: ^29.3.1 - jest-regex-util: ^29.2.0 - jest-resolve: ^29.3.1 - jest-snapshot: ^29.3.1 - jest-util: ^29.3.1 - slash: ^3.0.0 - strip-bom: ^4.0.0 - checksum: 82f27b48f000be074064a854e16e768f9453e9b791d8c5f9316606c37f871b5b10f70544c1b218ab9784f00bd972bb77f868c5ab6752c275be2cd219c351f5a7 - languageName: node - linkType: hard - -"jest-snapshot@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-snapshot@npm:29.3.1" - dependencies: - "@babel/core": ^7.11.6 - "@babel/generator": ^7.7.2 - "@babel/plugin-syntax-jsx": ^7.7.2 - "@babel/plugin-syntax-typescript": ^7.7.2 - "@babel/traverse": ^7.7.2 - "@babel/types": ^7.3.3 - "@jest/expect-utils": ^29.3.1 - "@jest/transform": ^29.3.1 - "@jest/types": ^29.3.1 - "@types/babel__traverse": ^7.0.6 - "@types/prettier": ^2.1.5 - babel-preset-current-node-syntax: ^1.0.0 - chalk: ^4.0.0 - expect: ^29.3.1 - graceful-fs: ^4.2.9 - jest-diff: ^29.3.1 - jest-get-type: ^29.2.0 - jest-haste-map: ^29.3.1 - jest-matcher-utils: ^29.3.1 - jest-message-util: ^29.3.1 - jest-util: ^29.3.1 - natural-compare: ^1.4.0 - pretty-format: ^29.3.1 - semver: ^7.3.5 - checksum: d7d0077935e78c353c828be78ccb092e12ba7622cb0577f21641fadd728ae63a7c1f4a0d8113bfb38db3453a64bfa232fb1cdeefe0e2b48c52ef4065b0ab75ae - languageName: node - linkType: hard - -"jest-util@npm:^29.0.0, jest-util@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-util@npm:29.3.1" +"istanbul-lib-coverage@npm:^3.0.0, istanbul-lib-coverage@npm:^3.2.0": + version: 3.2.0 + resolution: "istanbul-lib-coverage@npm:3.2.0" + checksum: a2a545033b9d56da04a8571ed05c8120bf10e9bce01cf8633a3a2b0d1d83dff4ac4fe78d6d5673c27fc29b7f21a41d75f83a36be09f82a61c367b56aa73c1ff9 + languageName: node + linkType: hard + +"istanbul-lib-report@npm:^3.0.0": + version: 3.0.0 + resolution: "istanbul-lib-report@npm:3.0.0" dependencies: - "@jest/types": ^29.3.1 - "@types/node": "*" - chalk: ^4.0.0 - ci-info: ^3.2.0 - graceful-fs: ^4.2.9 - picomatch: ^2.2.3 - checksum: f67c60f062b94d21cb60e84b3b812d64b7bfa81fe980151de5c17a74eb666042d0134e2e756d099b7606a1fcf1d633824d2e58197d01d76dde1e2dc00dfcd413 + istanbul-lib-coverage: ^3.0.0 + make-dir: ^3.0.0 + supports-color: ^7.1.0 + checksum: 3f29eb3f53c59b987386e07fe772d24c7f58c6897f34c9d7a296f4000de7ae3de9eb95c3de3df91dc65b134c84dee35c54eee572a56243e8907c48064e34ff1b languageName: node linkType: hard -"jest-validate@npm:^29.3.1": - version: 29.3.1 - resolution: "jest-validate@npm:29.3.1" +"istanbul-reports@npm:^3.1.4": + version: 3.1.5 + resolution: "istanbul-reports@npm:3.1.5" dependencies: - "@jest/types": ^29.3.1 - camelcase: ^6.2.0 - chalk: ^4.0.0 - jest-get-type: ^29.2.0 - leven: ^3.1.0 - pretty-format: ^29.3.1 - checksum: 92584f0b8ac284235f12b3b812ccbc43ef6dea080a3b98b1aa81adbe009e962d0aa6131f21c8157b30ac3d58f335961694238a93d553d1d1e02ab264c923778c + html-escaper: ^2.0.0 + istanbul-lib-report: ^3.0.0 + checksum: 7867228f83ed39477b188ea07e7ccb9b4f5320b6f73d1db93a0981b7414fa4ef72d3f80c4692c442f90fc250d9406e71d8d7ab65bb615cb334e6292b73192b89 languageName: node linkType: hard -"jest-watcher@npm:^29.3.1": +"jest-util@npm:^29.3.1": version: 29.3.1 - resolution: "jest-watcher@npm:29.3.1" + resolution: "jest-util@npm:29.3.1" dependencies: - "@jest/test-result": ^29.3.1 "@jest/types": ^29.3.1 "@types/node": "*" - ansi-escapes: ^4.2.1 chalk: ^4.0.0 - emittery: ^0.13.1 - jest-util: ^29.3.1 - string-length: ^4.0.1 - checksum: 60d189473486c73e9d540406a30189da5a3c67bfb0fb4ad4a83991c189135ef76d929ec99284ca5a505fe4ee9349ae3c99b54d2e00363e72837b46e77dec9642 + ci-info: ^3.2.0 + graceful-fs: ^4.2.9 + picomatch: ^2.2.3 + checksum: f67c60f062b94d21cb60e84b3b812d64b7bfa81fe980151de5c17a74eb666042d0134e2e756d099b7606a1fcf1d633824d2e58197d01d76dde1e2dc00dfcd413 languageName: node linkType: hard @@ -6020,7 +5303,7 @@ __metadata: languageName: node linkType: hard -"jest-worker@npm:^29.1.2, jest-worker@npm:^29.3.1": +"jest-worker@npm:^29.1.2": version: 29.3.1 resolution: "jest-worker@npm:29.3.1" dependencies: @@ -6032,29 +5315,10 @@ __metadata: languageName: node linkType: hard -"jest@npm:29.3.1": - version: 29.3.1 - resolution: "jest@npm:29.3.1" - dependencies: - "@jest/core": ^29.3.1 - "@jest/types": ^29.3.1 - import-local: ^3.0.2 - jest-cli: ^29.3.1 - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true - bin: - jest: bin/jest.js - checksum: 613f4ec657b14dd84c0056b2fef1468502927fd551bef0b19d4a91576a609678fb316c6a5b5fc6120dd30dd4ff4569070ffef3cb507db9bb0260b28ddaa18d7a - languageName: node - linkType: hard - "js-sdsl@npm:^4.1.4": - version: 4.1.5 - resolution: "js-sdsl@npm:4.1.5" - checksum: 695f657ddc5be462b97cac4e8e60f37de28d628ee0e23016baecff0bb584a18dddb5caeac537a775030f180b5afd62133ac4481e7024c8d03a62d73e4da0713e + version: 4.2.0 + resolution: "js-sdsl@npm:4.2.0" + checksum: 2cd0885f7212afb355929d72ca105cb37de7e95ad6031e6a32619eaefa46735a7d0fb682641a0ba666e1519cb138fe76abc1eea8a34e224140c9d94c995171f1 languageName: node linkType: hard @@ -6065,18 +5329,6 @@ __metadata: languageName: node linkType: hard -"js-yaml@npm:^3.13.1": - version: 3.14.1 - resolution: "js-yaml@npm:3.14.1" - dependencies: - argparse: ^1.0.7 - esprima: ^4.0.0 - bin: - js-yaml: bin/js-yaml.js - checksum: bef146085f472d44dee30ec34e5cf36bf89164f5d585435a3d3da89e52622dff0b188a580e4ad091c3341889e14cb88cac6e4deb16dc5b1e9623bb0601fc255c - languageName: node - linkType: hard - "js-yaml@npm:^4.1.0": version: 4.1.0 resolution: "js-yaml@npm:4.1.0" @@ -6106,7 +5358,7 @@ __metadata: languageName: node linkType: hard -"json-parse-even-better-errors@npm:^2.3.0, json-parse-even-better-errors@npm:^2.3.1": +"json-parse-even-better-errors@npm:^2.3.1": version: 2.3.1 resolution: "json-parse-even-better-errors@npm:2.3.1" checksum: 798ed4cf3354a2d9ccd78e86d2169515a0097a5c133337807cdf7f1fc32e1391d207ccfc276518cc1d7d8d4db93288b8a50ba4293d212ad1336e52a8ec0a941f @@ -6150,13 +5402,6 @@ __metadata: languageName: node linkType: hard -"kleur@npm:^3.0.3": - version: 3.0.3 - resolution: "kleur@npm:3.0.3" - checksum: df82cd1e172f957bae9c536286265a5cdbd5eeca487cb0a3b2a7b41ef959fc61f8e7c0e9aeea9c114ccf2c166b6a8dd45a46fd619c1c569d210ecd2765ad5169 - languageName: node - linkType: hard - "klona@npm:^2.0.4": version: 2.0.5 resolution: "klona@npm:2.0.5" @@ -6211,13 +5456,6 @@ __metadata: languageName: node linkType: hard -"leven@npm:^3.1.0": - version: 3.1.0 - resolution: "leven@npm:3.1.0" - checksum: 638401d534585261b6003db9d99afd244dfe82d75ddb6db5c0df412842d5ab30b2ef18de471aaec70fe69a46f17b4ae3c7f01d8a4e6580ef7adb9f4273ad1e55 - languageName: node - linkType: hard - "levn@npm:^0.4.1": version: 0.4.1 resolution: "levn@npm:0.4.1" @@ -6235,13 +5473,6 @@ __metadata: languageName: node linkType: hard -"lines-and-columns@npm:^1.1.6": - version: 1.2.4 - resolution: "lines-and-columns@npm:1.2.4" - checksum: 0c37f9f7fa212b38912b7145e1cd16a5f3cd34d782441c3e6ca653485d326f58b3caccda66efce1c5812bde4961bbde3374fae4b0d11bf1226152337f3894aa5 - languageName: node - linkType: hard - "loader-runner@npm:^4.2.0": version: 4.3.0 resolution: "loader-runner@npm:4.3.0" @@ -6249,6 +5480,13 @@ __metadata: languageName: node linkType: hard +"local-pkg@npm:^0.4.2": + version: 0.4.2 + resolution: "local-pkg@npm:0.4.2" + checksum: 22be451353c25c4411b552bf01880ebc9e995b93574b2facc7757968d888356df59199cacada14162ab53bbc9da055bb692c907b4171f008dbce45a2afc777c1 + languageName: node + linkType: hard + "locate-path@npm:^5.0.0": version: 5.0.0 resolution: "locate-path@npm:5.0.0" @@ -6274,7 +5512,7 @@ __metadata: languageName: node linkType: hard -"lodash.memoize@npm:4.x, lodash.memoize@npm:^4.1.2": +"lodash.memoize@npm:^4.1.2": version: 4.1.2 resolution: "lodash.memoize@npm:4.1.2" checksum: 9ff3942feeccffa4f1fafa88d32f0d24fdc62fd15ded5a74a5f950ff5f0c6f61916157246744c620173dddf38d37095a92327d5fd3861e2063e736a5c207d089 @@ -6313,6 +5551,15 @@ __metadata: languageName: node linkType: hard +"loupe@npm:^2.3.1": + version: 2.3.6 + resolution: "loupe@npm:2.3.6" + dependencies: + get-func-name: ^2.0.0 + checksum: cc83f1b124a1df7384601d72d8d1f5fe95fd7a8185469fec48bb2e4027e45243949e7a013e8d91051a138451ff0552310c32aa9786e60b6a30d1e801bdc2163f + languageName: node + linkType: hard + "lower-case@npm:^2.0.2": version: 2.0.2 resolution: "lower-case@npm:2.0.2" @@ -6357,13 +5604,6 @@ __metadata: languageName: node linkType: hard -"make-error@npm:1.x": - version: 1.3.6 - resolution: "make-error@npm:1.3.6" - checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 - languageName: node - linkType: hard - "make-fetch-happen@npm:^10.0.3": version: 10.2.1 resolution: "make-fetch-happen@npm:10.2.1" @@ -6388,15 +5628,6 @@ __metadata: languageName: node linkType: hard -"makeerror@npm:1.0.12": - version: 1.0.12 - resolution: "makeerror@npm:1.0.12" - dependencies: - tmpl: 1.0.5 - checksum: b38a025a12c8146d6eeea5a7f2bf27d51d8ad6064da8ca9405fcf7bf9b54acd43e3b30ddd7abb9b1bfa4ddb266019133313482570ddb207de568f71ecfcf6060 - languageName: node - linkType: hard - "mdn-data@npm:2.0.14": version: 2.0.14 resolution: "mdn-data@npm:2.0.14" @@ -6596,11 +5827,11 @@ __metadata: linkType: hard "minipass@npm:^3.0.0, minipass@npm:^3.1.1, minipass@npm:^3.1.6": - version: 3.3.5 - resolution: "minipass@npm:3.3.5" + version: 3.3.6 + resolution: "minipass@npm:3.3.6" dependencies: yallist: ^4.0.0 - checksum: f89f02bcaa0e0e4bb4c44ec796008e69fbca62db0aba6ead1bc57d25bdaefdf42102130f4f9ecb7d9c6b6cd35ff7b0c7b97d001d3435da8e629fb68af3aea57e + checksum: a30d083c8054cee83cdcdc97f97e4641a3f58ae743970457b1489ce38ee1167b3aaf7d815cd39ec7a99b9c40397fd4f686e83750e73e652b21cb516f6d845e48 languageName: node linkType: hard @@ -6772,13 +6003,6 @@ __metadata: languageName: node linkType: hard -"node-int64@npm:^0.4.0": - version: 0.4.0 - resolution: "node-int64@npm:0.4.0" - checksum: d0b30b1ee6d961851c60d5eaa745d30b5c95d94bc0e74b81e5292f7c42a49e3af87f1eb9e89f59456f80645d679202537de751b7d72e9e40ceea40c5e449057e - languageName: node - linkType: hard - "node-releases@npm:^2.0.6": version: 2.0.6 resolution: "node-releases@npm:2.0.6" @@ -6947,7 +6171,7 @@ __metadata: languageName: node linkType: hard -"p-limit@npm:^3.0.2, p-limit@npm:^3.1.0": +"p-limit@npm:^3.0.2": version: 3.1.0 resolution: "p-limit@npm:3.1.0" dependencies: @@ -7019,18 +6243,6 @@ __metadata: languageName: node linkType: hard -"parse-json@npm:^5.2.0": - version: 5.2.0 - resolution: "parse-json@npm:5.2.0" - dependencies: - "@babel/code-frame": ^7.0.0 - error-ex: ^1.3.1 - json-parse-even-better-errors: ^2.3.0 - lines-and-columns: ^1.1.6 - checksum: 62085b17d64da57f40f6afc2ac1f4d95def18c4323577e1eced571db75d9ab59b297d1d10582920f84b15985cbfc6b6d450ccbf317644cfa176f3ed982ad87e2 - languageName: node - linkType: hard - "parse-node-version@npm:^1.0.1": version: 1.0.1 resolution: "parse-node-version@npm:1.0.1" @@ -7113,6 +6325,13 @@ __metadata: languageName: node linkType: hard +"pathval@npm:^1.1.1": + version: 1.1.1 + resolution: "pathval@npm:1.1.1" + checksum: 090e3147716647fb7fb5b4b8c8e5b55e5d0a6086d085b6cd23f3d3c01fcf0ff56fd3cc22f2f4a033bd2e46ed55d61ed8379e123b42afe7d531a2a5fc8bb556d6 + languageName: node + linkType: hard + "picocolors@npm:^1.0.0": version: 1.0.0 resolution: "picocolors@npm:1.0.0" @@ -7134,13 +6353,6 @@ __metadata: languageName: node linkType: hard -"pirates@npm:^4.0.4": - version: 4.0.5 - resolution: "pirates@npm:4.0.5" - checksum: c9994e61b85260bec6c4fc0307016340d9b0c4f4b6550a957afaaff0c9b1ad58fbbea5cfcf083860a25cb27a375442e2b0edf52e2e1e40e69934e08dcc52d227 - languageName: node - linkType: hard - "pkg-dir@npm:^4.1.0, pkg-dir@npm:^4.2.0": version: 4.2.0 resolution: "pkg-dir@npm:4.2.0" @@ -7569,17 +6781,6 @@ __metadata: languageName: node linkType: hard -"pretty-format@npm:^29.0.0, pretty-format@npm:^29.3.1": - version: 29.3.1 - resolution: "pretty-format@npm:29.3.1" - dependencies: - "@jest/schemas": ^29.0.0 - ansi-styles: ^5.0.0 - react-is: ^18.0.0 - checksum: 9917a0bb859cd7a24a343363f70d5222402c86d10eb45bcc2f77b23a4e67586257390e959061aec22762a782fe6bafb59bf34eb94527bc2e5d211afdb287eb4e - languageName: node - linkType: hard - "private@npm:^0.1.8": version: 0.1.8 resolution: "private@npm:0.1.8" @@ -7618,16 +6819,6 @@ __metadata: languageName: node linkType: hard -"prompts@npm:^2.0.1": - version: 2.4.2 - resolution: "prompts@npm:2.4.2" - dependencies: - kleur: ^3.0.3 - sisteransi: ^1.0.5 - checksum: d8fd1fe63820be2412c13bfc5d0a01909acc1f0367e32396962e737cb2fc52d004f3302475d5ce7d18a1e8a79985f93ff04ee03007d091029c3f9104bffc007d - languageName: node - linkType: hard - "proxy-addr@npm:~2.0.7": version: 2.0.7 resolution: "proxy-addr@npm:2.0.7" @@ -7761,13 +6952,6 @@ __metadata: languageName: node linkType: hard -"react-is@npm:^18.0.0": - version: 18.2.0 - resolution: "react-is@npm:18.2.0" - checksum: e72d0ba81b5922759e4aff17e0252bd29988f9642ed817f56b25a3e217e13eea8a7f2322af99a06edb779da12d5d636e9fda473d620df9a3da0df2a74141d53e - languageName: node - linkType: hard - "react@npm:18.2.0": version: 18.2.0 resolution: "react@npm:18.2.0" @@ -7968,13 +7152,6 @@ __metadata: languageName: node linkType: hard -"resolve.exports@npm:^1.1.0": - version: 1.1.0 - resolution: "resolve.exports@npm:1.1.0" - checksum: 52865af8edb088f6c7759a328584a5de6b226754f004b742523adcfe398cfbc4559515104bc2ae87b8e78b1e4de46c9baec400b3fb1f7d517b86d2d48a098a2d - languageName: node - linkType: hard - "resolve@npm:^1.14.2, resolve@npm:^1.20.0, resolve@npm:^1.22.1": version: 1.22.1 resolution: "resolve@npm:1.22.1" @@ -8033,27 +7210,37 @@ __metadata: languageName: node linkType: hard +"rollup@npm:^2.79.1": + version: 2.79.1 + resolution: "rollup@npm:2.79.1" + dependencies: + fsevents: ~2.3.2 + dependenciesMeta: + fsevents: + optional: true + bin: + rollup: dist/bin/rollup + checksum: 6a2bf167b3587d4df709b37d149ad0300692cc5deb510f89ac7bdc77c8738c9546ae3de9322b0968e1ed2b0e984571f5f55aae28fa7de4cfcb1bc5402a4e2be6 + languageName: node + linkType: hard + "root-workspace-0b6124@workspace:.": version: 0.0.0-use.local resolution: "root-workspace-0b6124@workspace:." dependencies: "@types/cross-spawn": 6.0.2 - "@types/jest": 29.2.3 "@types/rimraf": 3.0.2 "@typescript-eslint/eslint-plugin": 5.44.0 "@typescript-eslint/parser": 5.44.0 - cross-spawn: 7.0.3 + "@vitest/coverage-c8": 0.25.3 eslint: 8.28.0 eslint-config-prettier: 8.5.0 eslint-plugin-prettier: 4.2.1 - jest: 29.3.1 - jest-diff: 29.3.1 - jest-matcher-utils: 29.3.1 prettier: 2.8.0 rimraf: 3.0.2 tempy: 1.0.1 - ts-jest: 29.0.3 typescript: 4.9.3 + vitest: 0.25.3 languageName: unknown linkType: soft @@ -8142,17 +7329,6 @@ __metadata: languageName: node linkType: hard -"semver@npm:7.x, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8": - version: 7.3.8 - resolution: "semver@npm:7.3.8" - dependencies: - lru-cache: ^6.0.0 - bin: - semver: bin/semver.js - checksum: ba9c7cbbf2b7884696523450a61fee1a09930d888b7a8d7579025ad93d459b2d1949ee5bbfeb188b2be5f4ac163544c5e98491ad6152df34154feebc2cc337c1 - languageName: node - linkType: hard - "semver@npm:^5.6.0": version: 5.7.1 resolution: "semver@npm:5.7.1" @@ -8171,6 +7347,17 @@ __metadata: languageName: node linkType: hard +"semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8": + version: 7.3.8 + resolution: "semver@npm:7.3.8" + dependencies: + lru-cache: ^6.0.0 + bin: + semver: bin/semver.js + checksum: ba9c7cbbf2b7884696523450a61fee1a09930d888b7a8d7579025ad93d459b2d1949ee5bbfeb188b2be5f4ac163544c5e98491ad6152df34154feebc2cc337c1 + languageName: node + linkType: hard + "send@npm:0.18.0": version: 0.18.0 resolution: "send@npm:0.18.0" @@ -8292,13 +7479,6 @@ __metadata: languageName: node linkType: hard -"sisteransi@npm:^1.0.5": - version: 1.0.5 - resolution: "sisteransi@npm:1.0.5" - checksum: aba6438f46d2bfcef94cf112c835ab395172c75f67453fe05c340c770d3c402363018ae1ab4172a1026a90c47eaccf3af7b6ff6fa749a680c2929bd7fa2b37a4 - languageName: node - linkType: hard - "slash@npm:^3.0.0": version: 3.0.0 resolution: "slash@npm:3.0.0" @@ -8352,16 +7532,6 @@ __metadata: languageName: node linkType: hard -"source-map-support@npm:0.5.13": - version: 0.5.13 - resolution: "source-map-support@npm:0.5.13" - dependencies: - buffer-from: ^1.0.0 - source-map: ^0.6.0 - checksum: 933550047b6c1a2328599a21d8b7666507427c0f5ef5eaadd56b5da0fd9505e239053c66fe181bf1df469a3b7af9d775778eee283cbb7ae16b902ddc09e93a97 - languageName: node - linkType: hard - "source-map-support@npm:~0.5.20": version: 0.5.21 resolution: "source-map-support@npm:0.5.21" @@ -8406,13 +7576,6 @@ __metadata: languageName: node linkType: hard -"sprintf-js@npm:~1.0.2": - version: 1.0.3 - resolution: "sprintf-js@npm:1.0.3" - checksum: 19d79aec211f09b99ec3099b5b2ae2f6e9cdefe50bc91ac4c69144b6d3928a640bb6ae5b3def70c2e85a2c3d9f5ec2719921e3a59d3ca3ef4b2fd1a4656a0df3 - languageName: node - linkType: hard - "ssri@npm:^9.0.0": version: 9.0.1 resolution: "ssri@npm:9.0.1" @@ -8429,15 +7592,6 @@ __metadata: languageName: node linkType: hard -"stack-utils@npm:^2.0.3": - version: 2.0.6 - resolution: "stack-utils@npm:2.0.6" - dependencies: - escape-string-regexp: ^2.0.0 - checksum: 052bf4d25bbf5f78e06c1d5e67de2e088b06871fa04107ca8d3f0e9d9263326e2942c8bedee3545795fc77d787d443a538345eef74db2f8e35db3558c6f91ff7 - languageName: node - linkType: hard - "statuses@npm:2.0.1": version: 2.0.1 resolution: "statuses@npm:2.0.1" @@ -8452,16 +7606,6 @@ __metadata: languageName: node linkType: hard -"string-length@npm:^4.0.1": - version: 4.0.2 - resolution: "string-length@npm:4.0.2" - dependencies: - char-regex: ^1.0.2 - strip-ansi: ^6.0.0 - checksum: ce85533ef5113fcb7e522bcf9e62cb33871aa99b3729cec5595f4447f660b0cefd542ca6df4150c97a677d58b0cb727a3fe09ac1de94071d05526c73579bf505 - languageName: node - linkType: hard - "string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": version: 4.2.3 resolution: "string-width@npm:4.2.3" @@ -8500,13 +7644,6 @@ __metadata: languageName: node linkType: hard -"strip-bom@npm:^4.0.0": - version: 4.0.0 - resolution: "strip-bom@npm:4.0.0" - checksum: 9dbcfbaf503c57c06af15fe2c8176fb1bf3af5ff65003851a102749f875a6dbe0ab3b30115eccf6e805e9d756830d3e40ec508b62b3f1ddf3761a20ebe29d3f3 - languageName: node - linkType: hard - "strip-final-newline@npm:^2.0.0": version: 2.0.0 resolution: "strip-final-newline@npm:2.0.0" @@ -8530,6 +7667,15 @@ __metadata: languageName: node linkType: hard +"strip-literal@npm:^0.4.2": + version: 0.4.2 + resolution: "strip-literal@npm:0.4.2" + dependencies: + acorn: ^8.8.0 + checksum: 831cdcaba61bc82c14ef5ca423a64bb8044b3b128abd15dff454d3fd05b0dbc7b4403760a7a636923d3c2e71a8e65174cef28ee9aef61f9a66819f865da4fdda + languageName: node + linkType: hard + "stylehacks@npm:^5.1.1": version: 5.1.1 resolution: "stylehacks@npm:5.1.1" @@ -8656,9 +7802,9 @@ __metadata: languageName: node linkType: hard -"terser@npm:^5.10.0, terser@npm:^5.14.1, terser@npm:^5.14.2": - version: 5.15.1 - resolution: "terser@npm:5.15.1" +"terser@npm:^5.10.0, terser@npm:^5.14.1, terser@npm:^5.15.1": + version: 5.16.0 + resolution: "terser@npm:5.16.0" dependencies: "@jridgewell/source-map": ^0.3.2 acorn: ^8.5.0 @@ -8666,7 +7812,7 @@ __metadata: source-map-support: ~0.5.20 bin: terser: bin/terser - checksum: 9880a1e0956983a1ce5de204ea35121c0009fa41d582a6904ae850e1953a1a2cc021168439565280c5a8eee67c85a874175627e24989b046c7a72589b81c3979 + checksum: d035672bd28bd40ff80d83bea6bc6c85bddf41c18060e49c8b36a3aa45a0a6b4a59c6a56bdf52f9d3350587684d664f8ca26656c6084abeb951b85edf34e47ae languageName: node linkType: hard @@ -8695,10 +7841,24 @@ __metadata: languageName: node linkType: hard -"tmpl@npm:1.0.5": - version: 1.0.5 - resolution: "tmpl@npm:1.0.5" - checksum: cd922d9b853c00fe414c5a774817be65b058d54a2d01ebb415840960406c669a0fc632f66df885e24cb022ec812739199ccbdb8d1164c3e513f85bfca5ab2873 +"tinybench@npm:^2.3.1": + version: 2.3.1 + resolution: "tinybench@npm:2.3.1" + checksum: 74d45fa546d964a8123f98847fc59550945ed7f0d3e5a4ce0f9596d836b51c1d340c2ae0277a8023c15dc9ea3d7cb948a79173bfc46338c9b367c6323ea1eaf3 + languageName: node + linkType: hard + +"tinypool@npm:^0.3.0": + version: 0.3.0 + resolution: "tinypool@npm:0.3.0" + checksum: 92291c309ed8d004c1ee1ef7f610cd90352383f12c52b0ec16abd9ebc665c03626e7afbc9993df97f63e67fea002b5cc18ba5e8f90260643867cbcac278a183c + languageName: node + linkType: hard + +"tinyspy@npm:^1.0.2": + version: 1.0.2 + resolution: "tinyspy@npm:1.0.2" + checksum: 32096121aa8d52bb625ad62c9314b3e4daba4ab9ac428217b12b1e1dfe9860e3c94d54a7affa279cc70dc6f10d88c6ba46b51de68896b318a06d02f05e87dcc3 languageName: node linkType: hard @@ -8725,39 +7885,6 @@ __metadata: languageName: node linkType: hard -"ts-jest@npm:29.0.3": - version: 29.0.3 - resolution: "ts-jest@npm:29.0.3" - dependencies: - bs-logger: 0.x - fast-json-stable-stringify: 2.x - jest-util: ^29.0.0 - json5: ^2.2.1 - lodash.memoize: 4.x - make-error: 1.x - semver: 7.x - yargs-parser: ^21.0.1 - peerDependencies: - "@babel/core": ">=7.0.0-beta.0 <8" - "@jest/types": ^29.0.0 - babel-jest: ^29.0.0 - jest: ^29.0.0 - typescript: ">=4.3" - peerDependenciesMeta: - "@babel/core": - optional: true - "@jest/types": - optional: true - babel-jest: - optional: true - esbuild: - optional: true - bin: - ts-jest: cli.js - checksum: 541e51776d367fa2279af47f75af94b03e0538f1839ea9983de0f4ad7f188002f6eb1fc72440651d96daa62d25a7bc679a129c14e6ef291277eea9346751d56b - languageName: node - linkType: hard - "tslib@npm:^1.8.1": version: 1.14.1 resolution: "tslib@npm:1.14.1" @@ -8792,7 +7919,7 @@ __metadata: languageName: node linkType: hard -"type-detect@npm:4.0.8": +"type-detect@npm:^4.0.0, type-detect@npm:^4.0.5": version: 4.0.8 resolution: "type-detect@npm:4.0.8" checksum: 62b5628bff67c0eb0b66afa371bd73e230399a8d2ad30d852716efcc4656a7516904570cd8631a49a3ce57c10225adf5d0cbdcb47f6b0255fe6557c453925a15 @@ -8813,13 +7940,6 @@ __metadata: languageName: node linkType: hard -"type-fest@npm:^0.21.3": - version: 0.21.3 - resolution: "type-fest@npm:0.21.3" - checksum: e6b32a3b3877f04339bae01c193b273c62ba7bfc9e325b8703c4ee1b32dc8fe4ef5dfa54bf78265e069f7667d058e360ae0f37be5af9f153b22382cd55a9afe0 - languageName: node - linkType: hard - "type-is@npm:~1.6.18": version: 1.6.18 resolution: "type-is@npm:1.6.18" @@ -8981,7 +8101,7 @@ __metadata: languageName: node linkType: hard -"v8-to-istanbul@npm:^9.0.0, v8-to-istanbul@npm:^9.0.1": +"v8-to-istanbul@npm:^9.0.0": version: 9.0.1 resolution: "v8-to-istanbul@npm:9.0.1" dependencies: @@ -8999,12 +8119,82 @@ __metadata: languageName: node linkType: hard -"walker@npm:^1.0.8": - version: 1.0.8 - resolution: "walker@npm:1.0.8" +"vite@npm:^3.0.0": + version: 3.2.4 + resolution: "vite@npm:3.2.4" + dependencies: + esbuild: ^0.15.9 + fsevents: ~2.3.2 + postcss: ^8.4.18 + resolve: ^1.22.1 + rollup: ^2.79.1 + peerDependencies: + "@types/node": ">= 14" + less: "*" + sass: "*" + stylus: "*" + sugarss: "*" + terser: ^5.4.0 + dependenciesMeta: + fsevents: + optional: true + peerDependenciesMeta: + "@types/node": + optional: true + less: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + bin: + vite: bin/vite.js + checksum: 0f3e8f89c15809bd6bd8dec54b04b7c9b87374314d00928035f9d70190b4b220e8206b5d77a1e4097a5019cebf7862df4fbc11fbbb35c4f75f359999123d2c25 + languageName: node + linkType: hard + +"vitest@npm:0.25.3": + version: 0.25.3 + resolution: "vitest@npm:0.25.3" dependencies: - makeerror: 1.0.12 - checksum: ad7a257ea1e662e57ef2e018f97b3c02a7240ad5093c392186ce0bcf1f1a60bbadd520d073b9beb921ed99f64f065efb63dfc8eec689a80e569f93c1c5d5e16c + "@types/chai": ^4.3.3 + "@types/chai-subset": ^1.3.3 + "@types/node": "*" + acorn: ^8.8.0 + acorn-walk: ^8.2.0 + chai: ^4.3.6 + debug: ^4.3.4 + local-pkg: ^0.4.2 + source-map: ^0.6.1 + strip-literal: ^0.4.2 + tinybench: ^2.3.1 + tinypool: ^0.3.0 + tinyspy: ^1.0.2 + vite: ^3.0.0 + peerDependencies: + "@edge-runtime/vm": "*" + "@vitest/browser": "*" + "@vitest/ui": "*" + happy-dom: "*" + jsdom: "*" + peerDependenciesMeta: + "@edge-runtime/vm": + optional: true + "@vitest/browser": + optional: true + "@vitest/ui": + optional: true + happy-dom: + optional: true + jsdom: + optional: true + bin: + vitest: vitest.mjs + checksum: cd54de758f41295ef8a5304318b0de37f3182ec9b179d983cb0199dac89d51b80ee30124754703ef77ce4a1b675f3b02094ef96790889d5c9212dbab7490b4d0 languageName: node linkType: hard @@ -9287,16 +8477,6 @@ __metadata: languageName: node linkType: hard -"write-file-atomic@npm:^4.0.1": - version: 4.0.2 - resolution: "write-file-atomic@npm:4.0.2" - dependencies: - imurmurhash: ^0.1.4 - signal-exit: ^3.0.7 - checksum: 5da60bd4eeeb935eec97ead3df6e28e5917a6bd317478e4a85a5285e8480b8ed96032bbcc6ecd07b236142a24f3ca871c924ec4a6575e623ec1b11bf8c1c253c - languageName: node - linkType: hard - "ws@npm:^8.4.2": version: 8.11.0 resolution: "ws@npm:8.11.0" @@ -9340,13 +8520,6 @@ __metadata: languageName: node linkType: hard -"yargs-parser@npm:^21.0.1, yargs-parser@npm:^21.1.1": - version: 21.1.1 - resolution: "yargs-parser@npm:21.1.1" - checksum: ed2d96a616a9e3e1cc7d204c62ecc61f7aaab633dcbfab2c6df50f7f87b393993fe6640d017759fe112d0cb1e0119f2b4150a87305cc873fd90831c6a58ccf1c - languageName: node - linkType: hard - "yargs@npm:^16.2.0": version: 16.2.0 resolution: "yargs@npm:16.2.0" @@ -9362,21 +8535,6 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^17.3.1": - version: 17.6.2 - resolution: "yargs@npm:17.6.2" - dependencies: - cliui: ^8.0.1 - escalade: ^3.1.1 - get-caller-file: ^2.0.5 - require-directory: ^2.1.1 - string-width: ^4.2.3 - y18n: ^5.0.5 - yargs-parser: ^21.1.1 - checksum: 47da1b0d854fa16d45a3ded57b716b013b2179022352a5f7467409da5a04a1eef5b3b3d97a2dfc13e8bbe5f2ffc0afe3bc6a4a72f8254e60f5a4bd7947138643 - languageName: node - linkType: hard - "yocto-queue@npm:^0.1.0": version: 0.1.0 resolution: "yocto-queue@npm:0.1.0"