Skip to content

Commit

Permalink
puppeteer#744 unit tests for common console methods
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfward committed Sep 18, 2017
1 parent 2079bf9 commit 6d9cf3c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,33 @@ describe('Page', function() {
'Promise',
]);
}));
it('should emit an event for each console level', SX(async function(){
const messages = [];
page.on('consoleLog', msg => messages.push(msg));
page.on('consoleInfo', msg => messages.push(msg));
page.on('consoleWarning', msg => messages.push(msg));
page.on('consoleDir', msg => messages.push(msg));
page.on('consoleTrace', msg => messages.push(msg));
await Promise.all([
page.evaluate(() => {
console.log('log');
console.info('info');
console.warn('warn');
console.trace('trace');
console.dir('dir');
}),
// Wait for 5 events to hit.
waitForEvents(page, 'console', 5),
]);
expect(messages[0]).toContain('log');
expect(messages).toEqual([
'log',
'info',
'warn',
'trace',
'dir'
]);
}));
it('should not fail for window object', SX(async function() {
let windowObj = null;
page.once('console', arg => windowObj = arg);
Expand Down

0 comments on commit 6d9cf3c

Please sign in to comment.