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

Commit fd23742

Browse files
committed
chore(test): move error tests off of the control flow.
- Leave node scripts/errorTest.js commented out since it has something to do with the control flow where the exit code is not set. Also the breakpointhook.js file has issues we will need to address (Error: Cannot find module). - Add TODO block for slowHttpAndTimeout tests. - Update spec/errorTest to use const, let over var and async/await. - Add SELENIUM_PROMISE_MANAGER flag to plugins tests (currently missing) - Turn on the rest of test suite prior to updating to selenium 4 (basicConf using blocking proxy, unit tests, dependency tests, and typing tests)
1 parent 149a2ac commit fd23742

23 files changed

+129
-115
lines changed

circle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
name: Selenium Start
5353
background: true
5454
command: |
55+
./node_modules/webdriver-manager/bin/webdriver-manager update
5556
./node_modules/.bin/webdriver-manager-replacement update --gecko false
5657
./node_modules/.bin/webdriver-manager-replacement start --gecko false
5758

scripts/test.js

Lines changed: 70 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var Executor = require('./test/test_util').Executor;
55

66
var passingTests = [
77
'node built/cli.js spec/basicConf.js',
8-
// 'node built/cli.js spec/basicConf.js --useBlockingProxy',
8+
'node built/cli.js spec/basicConf.js --useBlockingProxy',
99
'node built/cli.js spec/multiConf.js',
1010
'node built/cli.js spec/altRootConf.js',
1111
'node built/cli.js spec/inferRootConf.js',
@@ -21,7 +21,7 @@ var passingTests = [
2121
'node built/cli.js spec/suitesConf.js --suite okmany',
2222
'node built/cli.js spec/suitesConf.js --suite okspec',
2323
'node built/cli.js spec/suitesConf.js --suite okmany,okspec',
24-
// 'node built/cli.js spec/plugins/smokeConf.js',
24+
'node built/cli.js spec/plugins/smokeConf.js',
2525
'node built/cli.js spec/plugins/multiPluginConf.js',
2626
'node built/cli.js spec/plugins/jasminePostTestConf.js',
2727
'node built/cli.js spec/plugins/mochaPostTestConf.js',
@@ -47,15 +47,15 @@ var passingTests = [
4747
// // Interactive Element Explorer tasks
4848
// 'node scripts/interactive_tests/interactive_test.js',
4949
// 'node scripts/interactive_tests/with_base_url.js',
50-
// // Unit tests
51-
// 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/unit_test.json',
52-
// // Dependency tests
53-
// 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/dependency_test.json',
54-
// // Typings tests
55-
// 'node spec/install/test.js'
50+
// Unit tests
51+
'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/unit_test.json',
52+
// Dependency tests
53+
'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/dependency_test.json',
54+
// Typings tests
55+
'node spec/install/test.js'
5656
];
5757

58-
var executor = new Executor();
58+
const executor = new Executor();
5959

6060
passingTests.forEach(function(passing_test) {
6161
executor.addCommandlineTest(passing_test)
@@ -67,64 +67,65 @@ passingTests.forEach(function(passing_test) {
6767
*************************/
6868

6969
// assert stacktrace shows line of failure
70-
// executor.addCommandlineTest('node built/cli.js spec/errorTest/singleFailureConf.js')
71-
// .expectExitCode(1)
72-
// .expectErrors({
73-
// stackTrace: 'single_failure_spec1.js:5:32'
74-
// });
75-
76-
// // assert timeout works
77-
// executor.addCommandlineTest('node built/cli.js spec/errorTest/timeoutConf.js')
78-
// .expectExitCode(1)
79-
// .expectErrors({
80-
// message: 'Timeout - Async callback was not invoked within timeout ' +
81-
// 'specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'
82-
// })
83-
// .expectTestDuration(0, 1000);
84-
85-
// executor.addCommandlineTest('node built/cli.js spec/errorTest/afterLaunchChangesExitCodeConf.js')
86-
// .expectExitCode(11)
87-
// .expectErrors({
88-
// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.'
89-
// });
90-
91-
// executor.addCommandlineTest('node built/cli.js spec/errorTest/multiFailureConf.js')
92-
// .expectExitCode(1)
93-
// .expectErrors([{
94-
// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',
95-
// stacktrace: 'single_failure_spec1.js:5:32'
96-
// }, {
97-
// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',
98-
// stacktrace: 'single_failure_spec2.js:5:32'
99-
// }]);
100-
101-
// executor.addCommandlineTest('node built/cli.js spec/errorTest/shardedFailureConf.js')
102-
// .expectExitCode(1)
103-
// .expectErrors([{
104-
// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',
105-
// stacktrace: 'single_failure_spec1.js:5:32'
106-
// }, {
107-
// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',
108-
// stacktrace: 'single_failure_spec2.js:5:32'
109-
// }]);
110-
111-
// executor.addCommandlineTest('node built/cli.js spec/errorTest/mochaFailureConf.js')
112-
// .expectExitCode(1)
113-
// .expectErrors([{
114-
// message: 'expected \'My AngularJS App\' to equal \'INTENTIONALLY INCORRECT\'',
115-
// stacktrace: 'mocha_failure_spec.js:11:20'
116-
// }]);
117-
118-
// executor.addCommandlineTest('node built/cli.js spec/errorTest/pluginsFailingConf.js')
119-
// .expectExitCode(1)
120-
// .expectErrors([
121-
// {message: 'Expected true to be false'},
122-
// {message: 'from setup'},
123-
// {message: 'from postTest passing'},
124-
// {message: 'from postTest failing'},
125-
// {message: 'from teardown'}
126-
// ]);
127-
70+
executor.addCommandlineTest('node built/cli.js spec/errorTest/singleFailureConf.js')
71+
.expectExitCode(1)
72+
.expectErrors({
73+
stackTrace: 'single_failure_spec1.js:5:38'
74+
});
75+
76+
// assert timeout works
77+
executor.addCommandlineTest('node built/cli.js spec/errorTest/timeoutConf.js')
78+
.expectExitCode(1)
79+
.expectErrors({
80+
message: 'Timeout - Async callback was not invoked within timeout ' +
81+
'specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'
82+
})
83+
.expectTestDuration(0, 1000);
84+
85+
executor.addCommandlineTest('node built/cli.js spec/errorTest/afterLaunchChangesExitCodeConf.js')
86+
.expectExitCode(11)
87+
.expectErrors({
88+
message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.'
89+
});
90+
91+
executor.addCommandlineTest('node built/cli.js spec/errorTest/multiFailureConf.js')
92+
.expectExitCode(1)
93+
.expectErrors([{
94+
message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',
95+
stacktrace: 'single_failure_spec1.js:5:32'
96+
}, {
97+
message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',
98+
stacktrace: 'single_failure_spec2.js:5:32'
99+
}]);
100+
101+
executor.addCommandlineTest('node built/cli.js spec/errorTest/shardedFailureConf.js')
102+
.expectExitCode(1)
103+
.expectErrors([{
104+
message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',
105+
stacktrace: 'single_failure_spec1.js:5:32'
106+
}, {
107+
message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',
108+
stacktrace: 'single_failure_spec2.js:5:32'
109+
}]);
110+
111+
executor.addCommandlineTest('node built/cli.js spec/errorTest/mochaFailureConf.js')
112+
.expectExitCode(1)
113+
.expectErrors([{
114+
message: 'expected \'My AngularJS App\' to equal \'INTENTIONALLY INCORRECT\'',
115+
stacktrace: 'mocha_failure_spec.js:11:20'
116+
}]);
117+
118+
executor.addCommandlineTest('node built/cli.js spec/errorTest/pluginsFailingConf.js')
119+
.expectExitCode(1)
120+
.expectErrors([
121+
{message: 'Expected true to be false'},
122+
{message: 'from setup'},
123+
{message: 'from postTest passing'},
124+
{message: 'from postTest failing'},
125+
{message: 'from teardown'}
126+
]);
127+
128+
// TODO(selenium4): turn these on when we figure out the correct error message handling.
128129
// executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js')
129130
// .expectExitCode(1)
130131
// .expectErrors([
@@ -135,6 +136,7 @@ passingTests.forEach(function(passing_test) {
135136
// '*}'}
136137
// ]);
137138

139+
// TODO(selenium4): turn these on when we figure out the correct error message handling.
138140
// executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js ' +
139141
// '--untrackOutstandingTimeouts true')
140142
// .expectExitCode(1)
@@ -144,6 +146,7 @@ passingTests.forEach(function(passing_test) {
144146
// 'Locator: by.binding\\(\\"slowAngularTimeoutStatus\\"\\)$'}
145147
// ]);
146148

149+
// TODO(selenium4): turn these on when we figure out the correct error message handling.
147150
// executor.addCommandlineTest('node built/cli.js spec/angular2TimeoutConf.js')
148151
// .expectExitCode(1)
149152
// .expectErrors([

spec/errorTest/afterLaunchChangesExitCodeConf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var env = require('../environment.js');
22

33
exports.config = {
44
seleniumAddress: env.seleniumAddress,
5+
SELENIUM_PROMISE_MANAGER: false,
56

67
framework: 'jasmine',
78

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
describe('finding an element that does not exist', function() {
2-
it('should throw an error', function() {
3-
browser.get('index.html');
1+
describe('finding an element that does not exist', () => {
2+
it('should throw an error', async () => {
3+
await browser.get('index.html');
44
element(by.binding('INVALID')); // greeting
55
});
66
});
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Use the external Chai As Promised to deal with resolving promises in
22
// expectations.
3-
var chai = require('chai');
4-
var chaiAsPromised = require('chai-as-promised');
3+
const chai = require('chai');
4+
const chaiAsPromised = require('chai-as-promised');
55
chai.use(chaiAsPromised);
6-
var expect = chai.expect;
6+
const expect = chai.expect;
77

8-
describe('protractor library', function() {
9-
it('should fail', function() {
10-
browser.get('index.html');
11-
expect(browser.getTitle()).to.eventually.equal('INTENTIONALLY INCORRECT');
8+
describe('protractor library', () => {
9+
it('should fail', async () => {
10+
await browser.get('index.html');
11+
expect(await browser.getTitle()).to.equal('INTENTIONALLY INCORRECT');
1212
});
1313
});
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
describe('single failure spec1', function() {
2-
it('should fail expectation', function() {
3-
browser.get('index.html');
4-
var greeting = element(by.binding('greeting'));
5-
expect(greeting.getText()).toEqual('INTENTIONALLY INCORRECT');
1+
describe('single failure spec1', () => {
2+
it('should fail expectation', async () => {
3+
await browser.get('index.html');
4+
const greeting = element(by.binding('greeting'));
5+
expect(await greeting.getText()).toEqual('INTENTIONALLY INCORRECT');
66
});
77
});
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
describe('single failure spec2', function() {
2-
it('should fail expectation', function() {
3-
browser.get('index.html');
4-
var greeting = element(by.binding('greeting'));
5-
expect(greeting.getText()).toEqual('INTENTIONALLY INCORRECT');
1+
describe('single failure spec2', () => {
2+
it('should fail expectation', async () => {
3+
await browser.get('index.html');
4+
const greeting = element(by.binding('greeting'));
5+
expect(await greeting.getText()).toEqual('INTENTIONALLY INCORRECT');
66
});
77
});
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
describe('slow asynchronous events', function() {
2-
beforeEach(function() {
3-
browser.get('index.html#/async');
1+
describe('slow asynchronous events', () => {
2+
beforeEach(async () => {
3+
await browser.get('index.html#/async');
44
});
55

6-
it('waits for http calls', function() {
7-
var status = element(by.binding('slowHttpStatus'));
8-
var button = element(by.css('[ng-click="slowHttp()"]'));
6+
it('waits for http calls', async () => {
7+
const status = element(by.binding('slowHttpStatus'));
8+
const button = element(by.css('[ng-click="slowHttp()"]'));
99

10-
expect(status.getText()).toEqual('not started');
10+
expect(await status.getText()).toEqual('not started');
1111

12-
button.click();
12+
await button.click();
1313

14-
expect(status.getText()).toEqual('done');
14+
expect(await status.getText()).toEqual('done');
1515
});
1616

17-
it('waits for $timeout', function() {
18-
var status = element(by.binding('slowAngularTimeoutStatus'));
19-
var button = element(by.css('[ng-click="slowAngularTimeout()"]'));
17+
it('waits for $timeout', async () => {
18+
const status = element(by.binding('slowAngularTimeoutStatus'));
19+
const button = element(by.css('[ng-click="slowAngularTimeout()"]'));
2020

21-
expect(status.getText()).toEqual('not started');
21+
expect(await status.getText()).toEqual('not started');
2222

23-
button.click();
23+
await button.click();
2424

25-
expect(status.getText()).toEqual('done');
25+
expect(await status.getText()).toEqual('done');
2626
});
2727
});
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
describe('success spec', function() {
2-
it('should pass', function() {
3-
browser.get('index.html');
4-
var greeting = element(by.binding('greeting'));
5-
expect(greeting.getText()).toEqual('Hiya');
1+
describe('success spec', () => {
2+
it('should pass', async () => {
3+
await browser.get('index.html');
4+
const greeting = element(by.binding('greeting'));
5+
expect(await greeting.getText()).toEqual('Hiya');
66
});
77
});
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
describe('timeout spec', function() {
2-
it('should timeout due to jasmine spec limit', function() {
3-
browser.get('index.html#/form');
1+
describe('timeout spec', () => {
2+
it('should timeout due to jasmine spec limit', async () => {
3+
await browser.get('index.html#/form');
44
}, 1);
55
});

0 commit comments

Comments
 (0)