Skip to content

Commit 73e6ba0

Browse files
committed
test: fix test that was not testing what it claimed
1 parent de6ea4e commit 73e6ba0

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

packages/parser/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/** @type {import('@jest/types').Config.InitialOptions} */
44
module.exports = {
5+
setupFilesAfterEnv: ['jest-extended/all'],
56
testEnvironment: 'node',
67
testRegex: '/__tests__/(test|.*\\.test)\\.ts$',
78
transform: {

packages/parser/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@types/node": "^24.2.1",
3030
"is-ci-cli": "^2.2.0",
3131
"jest": "^29.7.0",
32+
"jest-extended": "^6.0.0",
3233
"typescript": "^5.9.2"
3334
},
3435
"publishConfig": {

packages/parser/src/__tests__/test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { parse, buildOptions } from '..'
2+
import { ParserPlugin } from '@babel/parser'
23
import * as t from '@babel/types'
4+
import 'jest-extended'
35

46
test('defaults `sourceType` to "unambiguous"', () => {
57
expect(buildOptions().sourceType).toBe('unambiguous')
@@ -99,9 +101,18 @@ test('includes "decorators" plugin with options by default', () => {
99101
})
100102

101103
test('does not include "decorators" plugin if "decorators-legacy" is already enabled', () => {
102-
expect(buildOptions({ plugins: ['decorators-legacy'] })).not.toContain(
103-
'decorators'
104-
)
104+
function isDecoratorsPlugin(plugin: ParserPlugin): boolean {
105+
return (
106+
plugin === 'decorators' ||
107+
(Array.isArray(plugin) && plugin[0] === 'decorators')
108+
)
109+
}
110+
111+
expect(
112+
buildOptions({
113+
plugins: ['decorators-legacy'],
114+
}).plugins
115+
).not.toSatisfyAny(isDecoratorsPlugin)
105116
})
106117

107118
test('enables `topLevelAwait` even if `allowAwaitOutsideFunction` is disabled', () => {

pnpm-lock.yaml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)