Skip to content

Test runner Ava can't use .ts files when running yarn test #570

@onnimonni

Description

@onnimonni

I'm trying to run the tests for the project locally and ava in notion-utils seems to fail on my local environment because it can't figure out how to use tests with .ts extension.

$ ava

  Uncaught exception in src/normalize-url.test.ts

  TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/onnimonni/Projects/react-notion-x/packages/notion-utils/src/normalize-url.test.ts

  ✖ src/normalize-url.test.ts exited with a non-zero exit code: 1

  Uncaught exception in src/parse-page-id.test.ts

  TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/onnimonni/Projects/react-notion-x/packages/notion-utils/src/parse-page-id.test.ts

  ✖ src/parse-page-id.test.ts exited with a non-zero exit code: 1

When I check the logs from Github actions this part of the tests is working just fine.

I'm wondering what could be the difference between my environment and the Github actions.

Full Logs from my local environment:

$ yarn test
yarn run v1.22.22
$ run-s build
$ run-s clean
$ del packages/*/build
$ run-s build:*
$ tsc --build
$ lerna run build --no-private
lerna notice cli v4.0.0
lerna info Executing command in 4 packages: "yarn run build"
lerna info run Ran npm script 'build' in 'notion-utils' in 0.7s:
$ tsup
CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.2.3
CLI Using tsup config: /Users/onnimonni/Projects/react-notion-x/packages/notion-utils/tsup.config.ts
CLI Target: es2015
ESM Build start
ESM build/index.js     10.54 KB
ESM build/index.js.map 45.51 KB
ESM ⚡️ Build success in 14ms
lerna info run Ran npm script 'build' in 'notion-client' in 0.6s:
$ tsup
CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.2.3
CLI Using tsup config: /Users/onnimonni/Projects/react-notion-x/packages/notion-client/tsup.config.ts
CLI Target: node14
ESM Build start
ESM build/index.js     6.30 KB
ESM build/index.js.map 24.59 KB
ESM ⚡️ Build success in 9ms
lerna info run Ran npm script 'build' in 'react-notion-x' in 0.8s:
$ tsup
CLI Building entry: src/index.tsx, src/third-party/code.tsx, src/third-party/collection.tsx, src/third-party/equation.tsx, src/third-party/modal.tsx, src/third-party/pdf.tsx
CLI Using tsconfig: tsconfig.json
CLI tsup v6.2.3
CLI Using tsup config: /Users/onnimonni/Projects/react-notion-x/packages/react-notion-x/tsup.config.ts
CLI Target: es2015
CLI Building entry: src/index.tsx, src/third-party/code.tsx, src/third-party/collection.tsx, src/third-party/equation.tsx, src/third-party/modal.tsx, src/third-party/pdf.tsx
CLI Using tsconfig: tsconfig.json
CLI tsup v6.2.3
CLI Using tsup config: /Users/onnimonni/Projects/react-notion-x/packages/react-notion-x/tsup.config.ts
CLI Target: es2015
ESM Build start
ESM Build start
ESM build/index.js                  101.40 KB
ESM build/third-party/pdf.js        1.83 KB
ESM build/third-party/collection.js 250.96 KB
ESM build/third-party/modal.js      120.00 B
ESM build/third-party/code.js       70.53 KB
ESM build/third-party/equation.js   66.07 KB
ESM ⚡️ Build success in 60ms
ESM build/dev/index.js                      101.43 KB
ESM build/dev/third-party/pdf.js            1.86 KB
ESM build/dev/third-party/code.js           70.56 KB
ESM build/dev/third-party/equation.js       66.10 KB
ESM build/dev/third-party/modal.js          153.00 B
ESM build/dev/third-party/collection.js     250.99 KB
ESM build/dev/index.js.map                  170.94 KB
ESM build/dev/third-party/pdf.js.map        1.30 KB
ESM build/dev/third-party/modal.js.map      239.00 B
ESM build/dev/third-party/equation.js.map   116.09 KB
ESM build/dev/third-party/code.js.map       122.35 KB
ESM build/dev/third-party/collection.js.map 465.11 KB
ESM ⚡️ Build success in 69ms
lerna info run Ran npm script 'build' in 'notion-compat' in 0.5s:
$ tsup
CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.2.3
CLI Using tsup config: /Users/onnimonni/Projects/react-notion-x/packages/notion-compat/tsup.config.ts
CLI Target: node14
ESM Build start
ESM build/index.js     20.37 KB
ESM build/index.js.map 35.95 KB
ESM ⚡️ Build success in 9ms
lerna success run Ran npm script 'build' in 4 packages in 1.8s:
lerna success - notion-client
lerna success - notion-compat
lerna success - notion-utils
lerna success - react-notion-x
$ run-p test:*
$ lerna run test
$ eslint '**/*.{ts,tsx}'
$ prettier '**/*.{js,jsx,ts,tsx}' --check
lerna notice cli v4.0.0
lerna info Executing command in 3 packages: "yarn run test"
Checking formatting...
packages/notion-compat/src/notion-compat-api.tslerna ERR! yarn run test exited 1 in 'notion-utils'
lerna ERR! yarn run test stdout:
$ ava

  Uncaught exception in src/normalize-url.test.ts

  TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/onnimonni/Projects/react-notion-x/packages/notion-utils/src/normalize-url.test.ts

  ✖ src/normalize-url.test.ts exited with a non-zero exit code: 1

  Uncaught exception in src/parse-page-id.test.ts

  TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/onnimonni/Projects/react-notion-x/packages/notion-utils/src/parse-page-id.test.ts

  ✖ src/parse-page-id.test.ts exited with a non-zero exit code: 1
  ─

  2 uncaught exceptions
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run test stderr:
error Command failed with exit code 1.
lerna ERR! yarn run test exited 1 in 'notion-utils'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
packages/notion-types/src/collection-view.tsERROR: "test:unit" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions