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

Commit 7310d57

Browse files
committed
address PR comments
1 parent 6b25eee commit 7310d57

File tree

4 files changed

+47
-42
lines changed

4 files changed

+47
-42
lines changed

lib/frameworks/jasmine.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RunnerReporter.prototype.specStarted = function() {
1515
};
1616

1717
RunnerReporter.prototype.specDone = function(result) {
18-
let specInfo = {
18+
const specInfo = {
1919
name: result.description,
2020
category: result.fullName.slice(0, -result.description.length).trim()
2121
};
@@ -26,7 +26,7 @@ RunnerReporter.prototype.specDone = function(result) {
2626
this.failedCount++;
2727
}
2828

29-
let entry = {
29+
const entry = {
3030
description: result.fullName,
3131
assertions: [],
3232
duration: new Date().getTime() - this.startTime.getTime()
@@ -57,16 +57,16 @@ RunnerReporter.prototype.specDone = function(result) {
5757
*/
5858
exports.run = async function(runner, specs) {
5959
const JasmineRunner = require('jasmine');
60-
let jrunner = new JasmineRunner();
60+
const jrunner = new JasmineRunner();
6161

62-
let jasmineNodeOpts = runner.getConfig().jasmineNodeOpts;
62+
const jasmineNodeOpts = runner.getConfig().jasmineNodeOpts;
6363

6464
// On timeout, the flow should be reset. This will prevent webdriver tasks
6565
// from overflowing into the next test and causing it to fail or timeout
6666
// as well. This is done in the reporter instead of an afterEach block
6767
// to ensure that it runs after any afterEach() blocks with webdriver tasks
6868
// get to complete first.
69-
let reporter = new RunnerReporter(runner);
69+
const reporter = new RunnerReporter(runner);
7070
jasmine.getEnv().addReporter(reporter);
7171

7272
// Add hooks for afterEach
@@ -100,7 +100,7 @@ exports.run = async function(runner, specs) {
100100
jasmine.DEFAULT_TIMEOUT_INTERVAL = jasmineNodeOpts.defaultTimeoutInterval;
101101
}
102102

103-
let originalOnComplete = runner.getConfig().onComplete;
103+
const originalOnComplete = runner.getConfig().onComplete;
104104

105105
jrunner.onComplete(async(passed) => {
106106
try {

lib/frameworks/mocha.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
exports.run = (runner, specs) => {
99
const Mocha = require('mocha');
10-
let mocha = new Mocha(runner.getConfig().mochaOpts);
10+
const mocha = new Mocha(runner.getConfig().mochaOpts);
1111

1212
// Add hooks for afterEach
1313
require('./setupAfterEach').setup(runner, specs);
@@ -130,4 +130,4 @@ exports.run = (runner, specs) => {
130130
reject(err);
131131
}
132132
});
133-
};
133+
};

lib/util.ts

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,34 @@ export function filterStackTrace(text: string): string {
3434
* @param {Array.<object>}} args The args to pass into filenameOrFn.
3535
* @return {Promise} A promise that will resolve when filenameOrFn completes.
3636
*/
37-
export function runFilenameOrFn_(configDir: string, filenameOrFn: any, args?: any[]): Promise<any> {
38-
return new Promise(async (resolve) => {
39-
if (filenameOrFn && !(typeof filenameOrFn === 'string' || typeof filenameOrFn === 'function')) {
40-
throw new Error('filenameOrFn must be a string or function');
41-
}
37+
export async function runFilenameOrFn_(configDir: string, filenameOrFn: any, args?: any[]): Promise<any> {
38+
if (filenameOrFn && !(typeof filenameOrFn === 'string' || typeof filenameOrFn === 'function')) {
39+
throw new Error('filenameOrFn must be a string or function');
40+
}
4241

43-
if (typeof filenameOrFn === 'string') {
44-
filenameOrFn = require(path.resolve(configDir, filenameOrFn));
45-
}
46-
if (typeof filenameOrFn === 'function') {
47-
let results;
48-
try {
49-
results = await filenameOrFn.apply(null, args);
50-
} catch (err) {
51-
if (typeof err === 'string') {
52-
err = new Error(err);
53-
} else {
54-
err = err as Error;
55-
if (!err.stack) {
56-
err.stack = new Error().stack;
57-
}
42+
if (typeof filenameOrFn === 'string') {
43+
filenameOrFn = require(path.resolve(configDir, filenameOrFn));
44+
}
45+
if (typeof filenameOrFn === 'function') {
46+
let results;
47+
try {
48+
results = await filenameOrFn.apply(null, args);
49+
} catch (err) {
50+
if (typeof err === 'string') {
51+
err = new Error(err);
52+
} else {
53+
err = err as Error;
54+
if (!err.stack) {
55+
err.stack = new Error().stack;
5856
}
59-
err.stack = exports.filterStackTrace(err.stack);
60-
throw err;
6157
}
62-
resolve(results);
63-
} else {
64-
resolve(undefined);
58+
err.stack = exports.filterStackTrace(err.stack);
59+
throw err;
6560
}
66-
});
61+
return results;
62+
} else {
63+
return undefined;
64+
}
6765
}
6866

6967
/**

spec/driverProviderTest.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ testDriverProvider(new Direct(chromeConfig)).
4848
then(() => {
4949
console.log('direct.dp with chrome working!');
5050
}, (err) => {
51-
console.log('direct.dp with chrome failed with', err);
51+
console.error('direct.dp with chrome failed with', err);
52+
throw err;
5253
});
5354

5455
const firefoxConfig = {
@@ -60,7 +61,8 @@ testDriverProvider(new Direct(firefoxConfig)).
6061
then(() => {
6162
console.log('direct.dp with firefox working!');
6263
}, (err) => {
63-
console.log('direct.dp with firefox failed with', err);
64+
console.error('direct.dp with firefox failed with', err);
65+
throw err;
6466
});
6567

6668
const hostedConfig = {
@@ -73,7 +75,8 @@ testDriverProvider(new Hosted(hostedConfig)).
7375
then(() => {
7476
console.log('hosted.dp working!');
7577
}, (err) => {
76-
console.log('hosted.dp failed with', err);
78+
console.error('hosted.dp failed with', err);
79+
throw err;
7780
});
7881

7982
const hostedPromisedConfig = {
@@ -86,7 +89,8 @@ testDriverProvider(new Hosted(hostedPromisedConfig)).
8689
then(() => {
8790
console.log('hosted.dp with promises working!');
8891
}, (err) => {
89-
console.log('hosted.dp with promises failed with', err);
92+
console.error('hosted.dp with promises failed with', err);
93+
throw err;
9094
});
9195

9296
const localConfig = {
@@ -99,7 +103,8 @@ testDriverProvider(new Local(localConfig)).
99103
then(() => {
100104
console.log('local.dp working!');
101105
}, (err) => {
102-
console.log('local.dp failed with', err);
106+
console.error('local.dp failed with', err);
107+
throw err;
103108
});
104109

105110
if (argv.sauceUser && argv.sauceKey) {
@@ -115,7 +120,8 @@ if (argv.sauceUser && argv.sauceKey) {
115120
then(() => {
116121
console.log('sauce.dp working!');
117122
}, (err) => {
118-
console.log('sauce.dp failed with', err);
123+
console.error('sauce.dp failed with', err);
124+
throw err;
119125
});
120126
}
121127

@@ -133,6 +139,7 @@ if (argv.browserstackUser && argv.browserstackKey) {
133139
then(() => {
134140
console.log('browserstack.dp working!');
135141
}, (err) => {
136-
console.log('browserstack.dp failed with', err);
142+
console.error('browserstack.dp failed with', err);
143+
throw err;
137144
});
138-
}
145+
}

0 commit comments

Comments
 (0)