Skip to content

Commit 64812f5

Browse files
committed
test(e2e): add editing .babelrc case
1 parent 343612e commit 64812f5

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

e2e-tests/development-runtime/cypress/integration/functionality/babelrc.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
const TEST_ELEMENT = `test-element`
22

3+
after(() => {
4+
cy.exec(`npm run reset`)
5+
})
6+
7+
after(() => {
8+
cy.exec(`npm run reset`)
9+
})
10+
311
describe(`babelrc`, () => {
412
it(`Applies .babelrc`, () => {
513
cy.visit(`/babelrc/base/`).waitForRouteChange()
@@ -8,4 +16,24 @@ describe(`babelrc`, () => {
816
.invoke(`text`)
917
.should(`eq`, `babel-rc-is-used`)
1018
})
19+
20+
describe(`hot reload`, () => {
21+
it(`editing .babelrc`, () => {
22+
cy.visit(`/babelrc/edit/`).waitForRouteChange()
23+
24+
cy.getTestElement(TEST_ELEMENT)
25+
.invoke(`text`)
26+
.should(`eq`, `babel-rc-initial`)
27+
28+
cy.exec(
29+
`npm run update -- --file src/pages/babelrc/edit/.babelrc --replacements "babel-rc-initial:babel-rc-edited" --exact`
30+
)
31+
32+
cy.waitForHmr()
33+
34+
cy.getTestElement(TEST_ELEMENT)
35+
.invoke(`text`)
36+
.should(`eq`, `babel-rc-edited`)
37+
})
38+
})
1139
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"plugins": [
3+
[
4+
"babel-plugin-search-and-replace",
5+
{
6+
"rules": [
7+
{
8+
"search": "babel-rc-test",
9+
"replace": "babel-rc-initial",
10+
"searchTemplateStrings": true
11+
}
12+
13+
]
14+
}
15+
]
16+
],
17+
"presets": [
18+
"babel-preset-gatsby"
19+
]
20+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from "react"
2+
3+
export default function BabelrcEdit() {
4+
return (
5+
<>
6+
<p>
7+
Code block below should contain <code>babel-rc-initial</code> first and
8+
after edit it should contain <code>babel-rc-edited</code>
9+
</p>
10+
<pre data-testid="test-element">babel-rc-test</pre>
11+
</>
12+
)
13+
}

0 commit comments

Comments
 (0)