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

chore(test): use native promises instead of q on onPrepare #5005

Merged
merged 1 commit into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ var passingTests = [
// 'node built/cli.js spec/onCleanUpAsyncReturnValueConf.js',
// 'node built/cli.js spec/onCleanUpNoReturnValueConf.js',
// 'node built/cli.js spec/onCleanUpSyncReturnValueConf.js',
// 'node built/cli.js spec/onPrepareConf.js',
// 'node built/cli.js spec/onPrepareFileConf.js',
// 'node built/cli.js spec/onPreparePromiseConf.js',
// 'node built/cli.js spec/onPreparePromiseFileConf.js',
'node built/cli.js spec/onPrepareConf.js',
'node built/cli.js spec/onPrepareFileConf.js',
'node built/cli.js spec/onPreparePromiseConf.js',
'node built/cli.js spec/onPreparePromiseFileConf.js',
// 'node built/cli.js spec/mochaConf.js',
// 'node built/cli.js spec/withLoginConf.js',
// 'node built/cli.js spec/suitesConf.js --suite okmany',
Expand Down
9 changes: 5 additions & 4 deletions spec/onPrepare/asyncstartup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var q = require('q');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woot!


module.exports = q.fcall(function() {
module.exports = async() => {
browser.params.password = '12345';
}).delay(1000);
return await new Promise((resolve, _) => {
setTimeout(resolve, 1000);
});
}
4 changes: 2 additions & 2 deletions spec/onPrepare/onPrepare_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('onPrepare function in the config', function() {
it('should have a special variable set in onPrepare', function() {
describe('onPrepare function in the config', () => {
it('should have a special variable set in onPrepare', () => {
expect(browser.params.password).toEqual('12345');
});
});
5 changes: 3 additions & 2 deletions spec/onPrepareConf.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Configuration using a function in onPrepare to set a parameter before
// testing.
var env = require('./environment.js');
const env = require('./environment.js');

// The main suite of Protractor tests.
exports.config = {
mockSelenium: true,
SELENIUM_PROMISE_MANAGER: false,

framework: 'jasmine',

Expand All @@ -16,7 +17,7 @@ exports.config = {

baseUrl: env.baseUrl + '/ng1/',

onPrepare: function() {
onPrepare: () => {
browser.params.password = '12345';
}
};
3 changes: 2 additions & 1 deletion spec/onPrepareFileConf.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var env = require('./environment.js');
const env = require('./environment.js');

// Configuration using a string in onPrepare to load a file with code to
// execute once before tests.
exports.config = {
mockSelenium: true,
SELENIUM_PROMISE_MANAGER: false,

framework: 'jasmine',

Expand Down
12 changes: 7 additions & 5 deletions spec/onPreparePromiseConf.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Configuration using a function in onPrepare to set a parameter before
// testing.
var env = require('./environment.js');
const env = require('./environment.js');
var q = require('q');

// The main suite of Protractor tests.
exports.config = {
mockSelenium: true,
SELENIUM_PROMISE_MANAGER: false,

framework: 'jasmine',

Expand All @@ -17,9 +18,10 @@ exports.config = {

baseUrl: env.baseUrl + '/ng1/',

onPrepare: function() {
return q.fcall(function() {
browser.params.password = '12345';
}).delay(1000);
onPrepare: async() => {
browser.params.password = '12345';
return await new Promise(resolve => {
setTimeout(resolve, 1000);
});
}
};