Skip to content

Commit

Permalink
test: should not expect babel polyfill paths to be extension-less (#6106
Browse files Browse the repository at this point in the history
  • Loading branch information
sodatea committed Dec 4, 2020
1 parent 2dbe0be commit 17339d7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/@vue/babel-preset-app/__tests__/babel-preset.spec.js
Expand Up @@ -29,7 +29,7 @@ test('polyfill detection', () => {
// default includes
expect(code).not.toMatch(getAbsolutePolyfill('es.promise'))
// usage-based detection
expect(code).not.toMatch('"core-js/modules/es.map"')
expect(code).not.toMatch('core-js/modules/es.map')

;({ code } = babel.transformSync(`
const a = new Map()
Expand All @@ -45,7 +45,7 @@ test('polyfill detection', () => {
// promise polyfill alone doesn't work in IE, needs this as well. fix: #1642
expect(code).toMatch(getAbsolutePolyfill('es.array.iterator'))
// usage-based detection
expect(code).toMatch('"core-js/modules/es.map"')
expect(code).toMatch('core-js/modules/es.map')
})

test('modern mode always skips unnecessary polyfills', () => {
Expand All @@ -67,7 +67,7 @@ test('modern mode always skips unnecessary polyfills', () => {
// (modern: safari >= 10.1, es.promise: safrai >= 11)
// the custom configuration only expects to support safari >= 12
// so it can be skipped
expect(code).not.toMatch('es.promise"')
expect(code).not.toMatch('es.promise[^.]')
// es.promise.finally is supported in safari >= 13.0.3
// so still needs to be included
expect(code).toMatch('es.promise.finally')
Expand All @@ -89,10 +89,10 @@ test('modern mode always skips unnecessary polyfills', () => {
filename: 'test-entry-file.js'
}))
// default includes
expect(code).not.toMatch('es.promise"')
expect(code).not.toMatch('es.promise[^.]')
expect(code).not.toMatch('es.promise.finally')
// usage-based detection
expect(code).not.toMatch('"core-js/modules/es.map"')
expect(code).not.toMatch('core-js/modules/es.map')
expect(code).not.toMatch('es.global-this')
delete process.env.VUE_CLI_MODERN_BUILD
})
Expand Down Expand Up @@ -120,7 +120,7 @@ test('async/await', () => {
`.trim(), defaultOptions)
expect(code).toMatch(getAbsolutePolyfill('es.promise'))
// should use regenerator runtime
expect(code).toMatch(`"regenerator-runtime/runtime"`)
expect(code).toMatch(`regenerator-runtime/runtime`)
})

test('jsx', () => {
Expand Down Expand Up @@ -166,7 +166,7 @@ test('disable absoluteRuntime', () => {
filename: 'test-entry-file.js'
})

expect(code).toMatch('"@babel/runtime/helpers/toConsumableArray"')
expect(code).toMatch('@babel/runtime/helpers/toConsumableArray')
expect(code).not.toMatch(getAbsolutePolyfill('es.promise'))
})

Expand All @@ -187,8 +187,8 @@ test('should inject polyfills / helpers using "require" statements for a umd mod
}]],
filename: 'test-entry-file.js'
})
expect(code).toMatch('require("@babel/runtime/helpers/toConsumableArray")')
expect(code).toMatch('require("core-js/modules/es.promise")')
expect(code).toMatch('require("@babel/runtime/helpers/toConsumableArray')
expect(code).toMatch('require("core-js/modules/es.promise')
expect(code).not.toMatch('import ')
})

Expand All @@ -205,8 +205,8 @@ test('should inject polyfills / helpers using "import" statements for an es modu
filename: 'test-entry-file.js'
})

expect(code).toMatch('import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"')
expect(code).toMatch('import "core-js/modules/es.promise"')
expect(code).toMatch('import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray')
expect(code).toMatch('import "core-js/modules/es.promise')
expect(code).not.toMatch('require(')
})

Expand Down

0 comments on commit 17339d7

Please sign in to comment.