Skip to content

Commit 23f144a

Browse files
committed
test: test env variables in e2e
1 parent 7925cd5 commit 23f144a

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

e2e/cypress/integration/build/prod.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ context('wpackio-scripts serve', () => {
1313
it('dynamic import should work', () => {
1414
cy.get('#dyn-app').should('have.text', 'I am dynamically imported');
1515
});
16+
it('custom env should work', () => {
17+
cy.get('#env-app').should('have.text', 'Hello Tryout undefined');
18+
});
1619
it('SASS should work', () => {
1720
cy.get('#blue').should('have.css', 'color', 'rgb(0, 0, 255)');
1821
});

e2e/cypress/integration/serve/app.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ context('wpackio-scripts serve', () => {
4747
});
4848
});
4949
});
50+
it('custom env should work', () => {
51+
cy.get('#env-app').should('have.text', 'Hello Tryout undefined');
52+
});
5053
it('SASS should work', () => {
5154
cy.get('#blue').then(el => {
5255
expect(el).to.have.css('color', 'rgb(0, 0, 255)');

e2e/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<h1>This is for e2e testing</h1>
1919
<!-- App entry Nodes -->
2020
<div id="main-app"></div>
21+
<div id="env-app"></div>
2122
<div id="dyn-app"></div>
2223
<div id="ts-app"></div>
2324
<div id="ts-dyn-app"></div>

e2e/prod.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<h1>This is for e2e testing</h1>
1818
<!-- App entry Nodes -->
1919
<div id="main-app"></div>
20+
<div id="env-app"></div>
2021
<div id="dyn-app"></div>
2122
<div id="ts-app"></div>
2223
<div id="ts-dyn-app"></div>

e2e/src/app/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ const path = (__WPACKIO__.appName + __WPACKIO__.outputPath).replace(
1313
console.log(path);
1414

1515
const mainNode = document.querySelector('#main-app');
16+
const envNode = document.querySelector('#env-app');
1617
const dynamicNode = document.querySelector('#dyn-app');
1718
const imgTag = document.querySelector('#img-tag');
1819

1920
mainNode.textContent = 'This is main app';
21+
envNode.textContent = `${process.env.E2E_ENV} ${process.env.NOT_PRESENT}`;
2022
imgTag.innerHTML = `<img src="${img}" />`;
2123

2224
import('./dynamic').then(({ dynamic }) => {

0 commit comments

Comments
 (0)