Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit c445f72

Browse files
miherlosevAndreyBelym
authored andcommitted
Fixed 'Cannot use more than 1 reporter with testcafe 1.0' (close #10) (#11)
1 parent 1ea4f9a commit c445f72

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea
2+
.vscode
23
node_modules
34
.DS_Store
5+
package-lock.json

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,20 @@ Specifies the reporter or an array of reporters.
5252
Reporter can be specified by reporter name, or an object with following properties:
5353

5454
* `name` - name of the reporter,
55-
* `file` - the path to a file where reporter's output will be redirected,
56-
* `outStream` - an Writable Stream instance where reporter's output will be piped. The `file` property will be ignored if `outStream` is specified.
57-
55+
* `output` - the file path where the report is written or the output stream.
56+
5857
Examples:
5958
```js
6059
"reporter": "minimal"
6160
```
6261
```js
63-
"reporter": { "name": "json", "file": "report.json" }
62+
"reporter": { "name": "json", "output": "report.json" }
6463
```
6564
```js
66-
"reporter": { "name": "xunit", "outStream": fs.createWriteStream("report.xml") }
65+
"reporter": { "name": "xunit", "output": fs.createWriteStream("report.xml") }
6766
```
6867
```js
69-
"reporter": ["spec", { "name": "xunit", "outStream": fs.createWriteStream("report.xml") }]
68+
"reporter": ["spec", { "name": "xunit", "output": fs.createWriteStream("report.xml") }]
7069
```
7170
#### filter
7271

index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ module.exports = function gulpTestCafe (opts) {
6767

6868
opts.reporter.forEach(function (reporter) {
6969
if (typeof reporter === 'string')
70-
runner.reporter(reporter);
71-
else {
72-
runner.reporter(
73-
reporter.name || DEFAULT_REPORTER,
74-
reporter.file ? fs.createWriteStream(reporter.file) : reporter.outStream
75-
);
76-
}
70+
return;
71+
72+
reporter.name = reporter.name || DEFAULT_REPORTER;
7773
});
7874

75+
runner.reporter(opts.reporter);
76+
7977
if (opts.concurrency)
8078
runner.concurrency(opts.concurrency);
8179

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gulp-testcafe",
3-
"version": "0.9.2",
3+
"version": "1.0.0",
44
"description": "Run TestCafe tests using Gulp.",
55
"main": "index.js",
66
"directories": {

test/test.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ function createReportOutStream () {
99

1010
write: function (text) {
1111
this.data += text;
12+
},
13+
14+
end: function () {
1215
}
1316
};
1417
}
1518

16-
1719
it('Should run tests', function () {
1820
var reportStream = createReportOutStream();
1921

2022
var ps = gulpTestCafe({
2123
browsers: ['chrome', 'firefox'],
22-
reporter: { outStream: reportStream }
24+
reporter: { output: reportStream }
2325
});
2426

2527

@@ -45,7 +47,7 @@ it('Should fail if tests fail', function () {
4547

4648
var ps = gulpTestCafe({
4749
browsers: ['chrome'],
48-
reporter: { outStream: reportStream }
50+
reporter: { output: reportStream }
4951
});
5052

5153
var resultsPromise = Promise.race([
@@ -72,7 +74,7 @@ it('Should fail if configuration is incorrect', function () {
7274

7375
var ps = gulpTestCafe({
7476
browsers: ['chrome'],
75-
reporter: { name: 'unknown', outStream: reportStream },
77+
reporter: { name: 'unknown', output: reportStream },
7678
});
7779

7880
var resultsPromise = Promise.race([
@@ -98,7 +100,7 @@ it('Should use multiple reporters', function () {
98100

99101
var ps = gulpTestCafe({
100102
browsers: ['chrome', 'firefox'],
101-
reporter: [{ outStream: reportStream1 }, { name: 'json', outStream: reportStream2 }]
103+
reporter: [{ output: reportStream1 }, { name: 'json', output: reportStream2 }]
102104
});
103105

104106
var resultsPromise = Promise.race([

0 commit comments

Comments
 (0)