Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Add __DEV__ to jest environment #92

Merged
merged 1 commit into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/jest-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
module.exports = {
cache: true,
globals: {
// Parity with create-universal-package globals.
// https://github.com/rtsao/create-universal-package#globals
__NODE__: process.env.JEST_ENV === 'node',
__BROWSER__: process.env.JEST_ENV === 'jsdom',
__DEV__: process.env.NODE_ENV !== 'production',
},
rootDir: process.cwd(),
setupFiles: [
Expand Down
11 changes: 11 additions & 0 deletions test/cli/test-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,14 @@ test('`fusion test-app` coverage', async t => {
t.ok(response.stdout.includes('Uncovered Lines'));
t.end();
});

test('`fusion test-app` environment variables', async t => {
const dir = path.resolve(__dirname, '../fixtures/test-jest-app');
const args = `test-app --dir=${dir} --configPath=../../../build/jest-config.js --coverage --match=environment-variables`;

const cmd = `require('${runnerPath}').run('${args}')`;
const response = await exec(`node -e "${cmd}"`);
t.equal(countTests(response.stderr), 2, 'ran 2 tests');

t.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {test} from 'fusion-test-utils';

test('__DEV__ environment variable is set', assert => {
assert.equal(__DEV__, true);
});