forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.test.js
42 lines (36 loc) · 1.08 KB
/
env.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
'use strict';
const runJest = require('../runJest');
const getLog = result =>
result.stdout
.toString()
.split('\n')[1]
.trim();
describe('Environment override', () => {
it('uses jsdom when specified', () => {
const result = runJest('env-test', ['--env=jsdom']);
expect(result.status).toBe(0);
expect(getLog(result)).toBe('WINDOW');
});
it('uses node as default from package.json', () => {
const result = runJest('env-test');
expect(result.status).toBe(0);
expect(getLog(result)).toBe('NO WINDOW');
});
it('uses node when specified', () => {
const result = runJest('env-test', ['--env=node']);
expect(result.status).toBe(0);
expect(getLog(result)).toBe('NO WINDOW');
});
it('fails when the env is not available', () => {
const result = runJest('env-test', ['--env=banana']);
expect(result.status).toBe(1);
});
});