-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
index.js
53 lines (45 loc) · 1.29 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
import * as path from "path"
import preset from "../index"
import * as pathSerializer from "../utils/path-serializer"
expect.addSnapshotSerializer(pathSerializer)
describe(`babel-preset-gatsby`, () => {
let currentEnv
beforeEach(() => {
currentEnv = process.env.BABEL_ENV
process.env.BABEL_ENV = `production`
})
afterEach(() => {
process.env.BABEL_ENV = currentEnv
})
it.each([`develop-html`, `develop`, `build-javascript`, `build-html`])(
`should specify proper presets and plugins when stage is %s`,
stage => {
expect(preset(null, { stage })).toMatchSnapshot()
}
)
it(`Allows to configure browser targets`, () => {
const targets = `last 1 version`
const { presets } = preset(null, {
stage: `build-javascript`,
targets,
})
expect(presets[0]).toEqual([
expect.stringContaining(path.join(`@babel`, `preset-env`)),
expect.objectContaining({
targets,
}),
])
})
it(`Allows to configure react runtime`, () => {
const { presets } = preset(null, {
reactRuntime: `automatic`,
})
expect(presets[1]).toEqual([
expect.stringContaining(path.join(`@babel`, `preset-react`)),
expect.objectContaining({
pragma: undefined,
runtime: `automatic`,
}),
])
})
})