forked from DevExpress/testcafe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the capability to get browser console messages (closes DevExpress…
- Loading branch information
1 parent
e1d8e83
commit 8413a1b
Showing
10 changed files
with
200 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/functional/fixtures/api/es-next/console/pages/empty.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Console messages (empty page)</title> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
27 changes: 27 additions & 0 deletions
27
test/functional/fixtures/api/es-next/console/pages/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Console messages</title> | ||
</head> | ||
<body> | ||
<button id="trigger-messages">Trigger Messages</button> | ||
|
||
<a id="reload" href="./empty.html">Reload</a> | ||
|
||
<script> | ||
var counter = 1; | ||
|
||
function triggerMessages () { | ||
console.log('log' + counter); | ||
console.warn('warn' + counter); | ||
console.error('error' + counter); | ||
console.info('info' + counter); | ||
|
||
counter++; | ||
} | ||
|
||
triggerMessages(); | ||
document.querySelector('#trigger-messages').addEventListener('click', triggerMessages); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
describe('[API] t.getConsoleMessages()', function () { | ||
it('Should return messages from the console', function () { | ||
return runTests('./testcafe-fixtures/console-test.js', 't.getConsoleMessages'); | ||
}); | ||
|
||
it('Should format messages if several args were passed', function () { | ||
return runTests('./testcafe-fixtures/console-test.js', 'messages formatting'); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
test/functional/fixtures/api/es-next/console/testcafe-fixtures/console-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
fixture `Double Click`; | ||
|
||
|
||
test | ||
.page `http://localhost:3000/fixtures/api/es-next/console/pages/index.html` | ||
('t.getConsoleMessages', async t => { | ||
let messages = await t.getConsoleMessages(); | ||
|
||
await t | ||
.expect(messages.error).eql(['error1']) | ||
.expect(messages.warn).eql(['warn1']) | ||
.expect(messages.log).eql(['log1']) | ||
.expect(messages.info).eql(['info1']) | ||
|
||
.click('#trigger-messages') | ||
|
||
// Check the driver keeps the messages between page reloads | ||
.click('#reload'); | ||
|
||
messages = await t.getConsoleMessages(); | ||
|
||
await t | ||
.expect(messages.error).eql(['error1', 'error2']) | ||
.expect(messages.warn).eql(['warn1', 'warn2']) | ||
.expect(messages.log).eql(['log1', 'log2']) | ||
.expect(messages.info).eql(['info1', 'info2']); | ||
}); | ||
|
||
test | ||
.page `http://localhost:3000/fixtures/api/es-next/console/pages/empty.html` | ||
('messages formatting', async t => { | ||
/* eslint-disable no-console */ | ||
await t.eval(() => console.log('a', 1, null, void 0, ['b', 2], { c: 3 })); | ||
/* eslint-enable no-console */ | ||
|
||
const { log } = await t.getConsoleMessages(); | ||
|
||
await t.expect(log[0]).eql('a 1 null undefined b,2 [object Object]'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters