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.
should log concurrent requests (closes DevExpress#7977)
- Loading branch information
1 parent
d1c9bce
commit dd5f358
Showing
6 changed files
with
83 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
15 changes: 15 additions & 0 deletions
15
test/functional/fixtures/regression/gh-7977/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,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>gh-7977</title> | ||
</head> | ||
<body> | ||
<button>click me</button> | ||
<script> | ||
for (let i = 0; i < 100; i++) { | ||
fetch('http://localhost:3000/custom'); | ||
} | ||
</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,31 @@ | ||
const createTestCafe = require('../../../../../lib'); | ||
const { onlyInNativeAutomation } = require('../../../utils/skip-in'); | ||
const requestCounter = require('./testcafe-fixtures/requestCounter'); | ||
const path = require('path'); | ||
const expect = require('chai').expect; | ||
|
||
const EXPECTED_REQUEST_COUNT = 300; | ||
|
||
let testcafe = null; | ||
|
||
describe('[Regression](GH-7977)', function () { | ||
onlyInNativeAutomation('Should log all concurrent requests', function () { | ||
return createTestCafe('127.0.0.1', 1335, 1336) | ||
.then(tc => { | ||
testcafe = tc; | ||
}) | ||
.then(() => { | ||
return testcafe.createRunner() | ||
.browsers(`chrome:headless`) | ||
.concurrency(3) | ||
.src(path.join(__dirname, './testcafe-fixtures/index.js')) | ||
.run(); | ||
}) | ||
.then(() => { | ||
return testcafe.close(); | ||
}) | ||
.then(() => { | ||
expect(requestCounter.get()).eql(EXPECTED_REQUEST_COUNT); | ||
}); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
test/functional/fixtures/regression/gh-7977/testcafe-fixtures/index.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,18 @@ | ||
import { RequestLogger } from 'testcafe'; | ||
import requestCounter from './requestCounter'; | ||
|
||
const logger = new RequestLogger(/custom/); | ||
|
||
fixture `Concurrent request loggers` | ||
.page `http://localhost:3000/fixtures/regression/gh-7977/pages/index.html` | ||
.requestHooks(logger); | ||
|
||
for (let i = 0; i < 3; i++) { | ||
test(`send multiple requests - ${i}`, async t => { | ||
await t.wait(1000); | ||
|
||
requestCounter.add(logger.requests.length); | ||
}); | ||
} | ||
|
||
|
12 changes: 12 additions & 0 deletions
12
test/functional/fixtures/regression/gh-7977/testcafe-fixtures/requestCounter.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,12 @@ | ||
let count = 0; | ||
|
||
const requestCounter = { | ||
add (value) { | ||
count += value; | ||
}, | ||
get () { | ||
return count; | ||
}, | ||
}; | ||
|
||
module.exports = requestCounter; |