Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't report some unhandled errors correctly but shows TypeError #2264

Closed
6 tasks done
kaorukobo opened this issue Nov 3, 2022 · 0 comments · Fixed by #2266
Closed
6 tasks done

Doesn't report some unhandled errors correctly but shows TypeError #2264

kaorukobo opened this issue Nov 3, 2022 · 0 comments · Fixed by #2266

Comments

@kaorukobo
Copy link

kaorukobo commented Nov 3, 2022

Describe the bug

There is an error during test which is not correctly reported by vitest. As an example, it is a syntax error object thrown from sass npm.

Expected Output

# on Stackblitz reproduction attached below
$ ./node_modules/.bin/vitest run dump-error-by-hand.test.js

⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯

 FAIL  dump-error-by-hand.test.js > it
Error: Can't find stylesheet to import.
  ╷
1 │ @import "NeverSeenFile";
  │         ^^^^^^^^^^^^^^^
  ╵
  test.scss 1:9  root stylesheet
 ❯ wrapException node_modules/sass/sass.dart.js:1247:17
 ...

Actual Output

# on Stackblitz reproduction attached below
$ ./node_modules/.bin/vitest run issue.test.js

⎯⎯⎯ Unhandled Errors ⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯ Unhandled Errors ⎯⎯⎯
TypeError: class constructors must be invoked with 'new'
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Reproduction

by Stackblitz:

https://stackblitz.com/edit/node-hqdqwu?file=issue.test.js

by shell:

npm i sass@latest vitest@latest

cat > issue.test.js <<'EOS'
import { promises as fs } from 'fs';
import { test } from 'vitest';
import { compile } from 'sass';

test('it', async () => {
  await fs.writeFile('test.scss', '@import "NeverSeenFile";');
  compile('./test.scss', {});
});
EOS

./node_modules/.bin/vitest run issue.test.js

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    vitest: ^0.24.5 => 0.24.5

Used Package Manager

npm

Validations

@sheremet-va sheremet-va added the bug label Nov 3, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants