Files
create-react-app/packages/react-scripts/fixtures/kitchensink/integration/env.test.js
Valerii Sorokobatko 80a7fc391d Feature/different env config files #1343 (#1344)
* support different env configs.

* fomrat code

* Hide doc

* Slightly rework the PR

* Remove .env in default template
* Use just one entry in the paths
* Unify env.js and loadEnv.js

* Oops, forgot these folks
2017-05-12 11:30:59 +01:00

73 lines
2.2 KiB
JavaScript

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { expect } from 'chai';
import initDOM from './initDOM';
describe('Integration', () => {
describe('Environment variables', () => {
it('file env variables', async () => {
const doc = await initDOM('file-env-variables');
expect(
doc.getElementById('feature-file-env-original-1').textContent
).to.equal('from-original-env-1');
expect(
doc.getElementById('feature-file-env-original-2').textContent
).to.equal('override-from-original-local-env-2');
if (process.env.NODE_ENV === 'production') {
expect(doc.getElementById('feature-file-env').textContent).to.equal(
'production'
);
expect(doc.getElementById('feature-file-env-x').textContent).to.equal(
'x-from-production-env'
);
} else {
expect(doc.getElementById('feature-file-env').textContent).to.equal(
'development'
);
expect(doc.getElementById('feature-file-env-x').textContent).to.equal(
'x-from-development-env'
);
}
});
it('NODE_PATH', async () => {
const doc = await initDOM('node-path');
expect(
doc.getElementById('feature-node-path').childElementCount
).to.equal(4);
});
it('PUBLIC_URL', async () => {
const doc = await initDOM('public-url');
const prefix = process.env.NODE_ENV === 'development'
? ''
: 'http://www.example.org/spa';
expect(doc.getElementById('feature-public-url').textContent).to.equal(
`${prefix}.`
);
expect(
doc.querySelector('head link[rel="shortcut icon"]').getAttribute('href')
).to.equal(`${prefix}/favicon.ico`);
});
it('shell env variables', async () => {
const doc = await initDOM('shell-env-variables');
expect(
doc.getElementById('feature-shell-env-variables').textContent
).to.equal('fromtheshell.');
});
});
});