File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed
e2e-tests/development-runtime
cypress/integration/functionality Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -35,5 +35,57 @@ describe(`babelrc`, () => {
3535 . invoke ( `text` )
3636 . should ( `eq` , `babel-rc-edited` )
3737 } )
38+
39+ it ( `adding .babelrc` , ( ) => {
40+ cy . visit ( `/babelrc/add/` ) . waitForRouteChange ( )
41+
42+ cy . getTestElement ( TEST_ELEMENT )
43+ . invoke ( `text` )
44+ . should ( `eq` , `babel-rc-test` )
45+
46+ const FILE_CONTENT = `
47+ {
48+ "plugins": [
49+ [
50+ "babel-plugin-search-and-replace",
51+ {
52+ "rules": [
53+ {
54+ "search": "babel-rc-test",
55+ "replace": "babel-rc-added",
56+ "searchTemplateStrings": true
57+ }
58+
59+ ]
60+ }
61+ ]
62+ ],
63+ "presets": [
64+ "babel-preset-gatsby"
65+ ]
66+ }
67+ `
68+
69+ cy . exec (
70+ `npm run update -- --file src/pages/babelrc/add/.babelrc --file-content '${ JSON . stringify (
71+ FILE_CONTENT
72+ ) } '`
73+ )
74+
75+ // babel-loader doesn't actually hot reloads itself when new .babelrc file is added
76+ // this is because it registers dependency only if file already exists
77+ // ( https://github.com/babel/babel-loader/blob/1669ac07ee1eed28a8e6fcacbf1c07ceb06fe053/src/index.js#L214-L216 )
78+ // so to test hot-reloading here we actually have to invalidate js file, which would recompile it and discover
79+ // new babelrc file
80+ cy . exec (
81+ `npm run update -- --file src/pages/babelrc/add/index.js --replacements "foo-bar:foo-bar" --exact`
82+ )
83+
84+ cy . waitForHmr ( )
85+
86+ cy . getTestElement ( TEST_ELEMENT )
87+ . invoke ( `text` )
88+ . should ( `eq` , `babel-rc-added` )
89+ } )
3890 } )
3991} )
Original file line number Diff line number Diff line change 1+ import React from "react"
2+
3+ export default function BabelrcAdd ( ) {
4+ return (
5+ < >
6+ < p >
7+ Code block below should contain < code > babel-rc-test</ code > first and
8+ after .babelrc addition it should contain < code > babel-rc-added</ code >
9+ </ p >
10+ < pre data-testid = "test-element" > babel-rc-test</ pre >
11+ </ >
12+ )
13+ }
You can’t perform that action at this time.
0 commit comments