Skip to content

Commit

Permalink
Add __DEV__ to jest environment
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGrandon committed Dec 23, 2017
1 parent 34c5064 commit 08999f9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
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.only('`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);
});

0 comments on commit 08999f9

Please sign in to comment.