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

Commit

Permalink
quieter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xavdid committed Feb 28, 2018
1 parent 1a2aeca commit fd59bb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/tools/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const dotenv = require('dotenv');

const ensurePath = require('./ensure-path');

const { IS_TESTING } = require('../constants');

// Copy bundle environment into process.env, and vice versa,
// for convenience and compatibility with native environment vars.
const applyEnvironment = event => {
Expand Down Expand Up @@ -44,7 +46,7 @@ const injectEnvironmentFile = filename => {
if (result.error) {
// backwards compatibility
result = dotenv.load({ path: localFilepath('.environment') });
if (result.parsed) {
if (result.parsed && !IS_TESTING) {
console.log(
[
'\nWARNING: `.environment` files will no longer be read by default in the next major version.',
Expand Down
11 changes: 4 additions & 7 deletions test/tools/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const mock = require('mock-fs');
const tools = require('../../src/tools/exported');
let env;

describe.only('read env', () => {
describe('read env', () => {
beforeEach(() => {
env = Object.assign({}, process.env);
});

it('should should only read .env', done => {
it('should should only read .env', () => {
mock({
'.environment': 'CITY="boulder"\nNAME="david"\n',
'.env': 'PIZZA="Blackjack"\n',
Expand All @@ -19,22 +19,20 @@ describe.only('read env', () => {
tools.env.inject();
process.env.PIZZA.should.equal('Blackjack');
should.not.exist(process.env.CITY);
done();
});

// this is temporary in v6, removed for v7
it('should read .environment if .env is missing', done => {
it('should read .environment if .env is missing', () => {
mock({
'.environment': 'CITY="boulder"\nNAME="david"\n'
});

tools.env.inject();
process.env.CITY.should.equal('boulder');
should.not.exist(process.env.PIZZA);
done();
});

it('should parse a with filename, ignore defaults', done => {
it('should parse a with filename, ignore defaults', () => {
mock({
'.environment': 'CITY="boulder"\nNAME="david"\n',
'.env': 'PIZZA="Blackjack"\n',
Expand All @@ -45,7 +43,6 @@ describe.only('read env', () => {
process.env.SECRET.should.equal('very_secret_thing');
should.not.exist(process.env.CITY);
should.not.exist(process.env.PIZZA);
done();
});

afterEach(() => {
Expand Down

0 comments on commit fd59bb7

Please sign in to comment.