| 1 |
import _reactPreset from "../lib/index.js"; |
| 2 |
const reactPreset = _reactPreset.default || _reactPreset; |
| 3 |
|
| 4 |
describe("react preset", () => { |
| 5 |
it("does throw clear error when no options passed for Babel 6", () => { |
| 6 |
expect(() => { |
| 7 |
reactPreset({ version: "6.5.0" }); |
| 8 |
}).toThrow(Error, /Requires Babel "\^7.0.0-0"/); |
| 9 |
}); |
| 10 |
(process.env.BABEL_8_BREAKING ? it : it.skip)( |
| 11 |
"throws when unknown option is passed", |
| 12 |
() => { |
| 13 |
expect(() => { |
| 14 |
reactPreset({ assertVersion() {} }, { runtine: true }); |
| 15 |
}).toThrowErrorMatchingInlineSnapshot(` |
| 16 |
"@babel/preset-react: 'runtine' is not a valid top-level option. |
| 17 |
- Did you mean 'runtime'?" |
| 18 |
`); |
| 19 |
}, |
| 20 |
); |
| 21 |
(process.env.BABEL_8_BREAKING ? it : it.skip)( |
| 22 |
"throws when option is of incorrect type", |
| 23 |
() => { |
| 24 |
expect(() => { |
| 25 |
reactPreset({ assertVersion() {} }, { runtime: true }); |
| 26 |
}).toThrowErrorMatchingInlineSnapshot( |
| 27 |
`"@babel/preset-react: 'runtime' option must be a string."`, |
| 28 |
); |
| 29 |
}, |
| 30 |
); |
| 31 |
}); |