Skip to content

Commit

Permalink
tests: check render error without engine-specific message
Browse files Browse the repository at this point in the history
closes #3251
  • Loading branch information
kunalspathak authored and dougwilson committed Sep 22, 2017
1 parent d7da225 commit 19a2eeb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 4 additions & 6 deletions test/app.render.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ describe('app', function(){

app.set('views', path.join(__dirname, 'fixtures'))

app.render('user.tmpl', function (err, str) {
// nextTick to prevent cyclic
process.nextTick(function(){
err.message.should.match(/Cannot read property '[^']+' of undefined/);
done();
});
app.render('user.tmpl', function (err) {
assert.ok(err)
assert.equal(err.name, 'RenderError')
done()
})
})
})
Expand Down
10 changes: 6 additions & 4 deletions test/res.render.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ describe('res', function(){
});

app.use(function(err, req, res, next){
res.end(err.message);
res.status(500).send('got error: ' + err.name)
});

request(app)
.get('/')
.expect(/Cannot read property '[^']+' of undefined/, done);
.expect(500, 'got error: RenderError', done)
})
})

Expand Down Expand Up @@ -329,13 +329,15 @@ describe('res', function(){

app.use(function(req, res){
res.render('user.tmpl', function (err) {
res.end(err.message);
if (err) {
res.status(500).send('got error: ' + err.name)
}
});
});

request(app)
.get('/')
.expect(/Cannot read property '[^']+' of undefined/, done);
.expect(500, 'got error: RenderError', done)
})
})
})
Expand Down
1 change: 1 addition & 0 deletions test/support/tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function renderFile(fileName, options, callback) {
str = str.replace(variableRegExp, generateVariableLookup(options));
} catch (e) {
err = e;
err.name = 'RenderError'
}

callback(err, str);
Expand Down

0 comments on commit 19a2eeb

Please sign in to comment.