-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
index.js
72 lines (56 loc) · 1.92 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const preset = require(`../index.js`)
jest.mock(`../resolver`, () => jest.fn(moduleName => moduleName))
describe(`babel-preset-gatsby-package`, () => {
let babelEnv;
beforeEach(() => {
babelEnv = process.env.BABEL_ENV
delete process.env.BABEL_ENV;
})
afterEach(() => {
process.env.BABEL_ENV = babelEnv
})
describe(`in node mode`, () => {
it(`specifies the proper plugins`, () => {
const { plugins } = preset()
expect(plugins).toMatchSnapshot()
})
it(`specifies proper presets`, () => {
const { presets } = preset()
expect(presets).toMatchSnapshot()
})
it(`specifies proper presets for debugging`, () => {
const { presets } = preset(null, { debug: true })
expect(presets).toMatchSnapshot()
})
it(`can pass custom nodeVersion target`, () => {
const nodeVersion = `6.0`
const { presets } = preset(null, {
nodeVersion,
})
const [, opts] = presets.find(preset => [].concat(preset).includes(`@babel/preset-env`))
expect(opts.targets.node).toBe(nodeVersion)
})
it(`can enable compilerFlags`, () => {
const { plugins } = preset(null, { availableCompilerFlags: [`MAJOR`] })
expect(plugins).toMatchSnapshot()
})
})
describe(`in browser mode`, () => {
it(`specifies the proper plugins`, () => {
const { plugins } = preset(null, { browser: true })
expect(plugins).toMatchSnapshot()
})
it(`specifies proper presets`, () => {
const { presets } = preset(null, { browser: true })
expect(presets).toMatchSnapshot()
})
it(`specifies proper presets for debugging`, () => {
const { presets } = preset(null, { browser: true, debug: true })
expect(presets).toMatchSnapshot()
})
it(`specifies proper presets for esm`, () => {
const { presets } = preset(null, { browser: true, esm: true })
expect(presets).toMatchSnapshot()
})
})
})