Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a39e409

Browse filesBrowse files
committed
tests: prevent leaking changes to NODE_ENV
1 parent 82de4de commit a39e409
Copy full SHA for a39e409

File tree

Expand file treeCollapse file tree

1 file changed

+27
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+27
-6
lines changed

‎test/app.js

Copy file name to clipboardExpand all lines: test/app.js
+27-6Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,49 @@ describe('app.path()', function(){
8383
})
8484

8585
describe('in development', function(){
86+
before(function () {
87+
this.env = process.env.NODE_ENV
88+
process.env.NODE_ENV = 'development'
89+
})
90+
91+
after(function () {
92+
process.env.NODE_ENV = this.env
93+
})
94+
8695
it('should disable "view cache"', function(){
87-
process.env.NODE_ENV = 'development';
8896
var app = express();
8997
assert.ok(!app.enabled('view cache'))
90-
process.env.NODE_ENV = 'test';
9198
})
9299
})
93100

94101
describe('in production', function(){
102+
before(function () {
103+
this.env = process.env.NODE_ENV
104+
process.env.NODE_ENV = 'production'
105+
})
106+
107+
after(function () {
108+
process.env.NODE_ENV = this.env
109+
})
110+
95111
it('should enable "view cache"', function(){
96-
process.env.NODE_ENV = 'production';
97112
var app = express();
98113
assert.ok(app.enabled('view cache'))
99-
process.env.NODE_ENV = 'test';
100114
})
101115
})
102116

103117
describe('without NODE_ENV', function(){
118+
before(function () {
119+
this.env = process.env.NODE_ENV
120+
process.env.NODE_ENV = ''
121+
})
122+
123+
after(function () {
124+
process.env.NODE_ENV = this.env
125+
})
126+
104127
it('should default to development', function(){
105-
process.env.NODE_ENV = '';
106128
var app = express();
107129
assert.strictEqual(app.get('env'), 'development')
108-
process.env.NODE_ENV = 'test';
109130
})
110131
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.