|
1 | 1 | // Use the external Chai As Promised to deal with resolving promises in
|
2 | 2 | // 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'); |
5 | 5 | chai.use(chaiAsPromised);
|
6 | 6 |
|
7 |
| -var expect = chai.expect; |
| 7 | +const expect = chai.expect; |
8 | 8 |
|
9 | 9 | // Chai's expect().to.exist style makes default jshint unhappy.
|
10 | 10 | // jshint expr:true
|
11 | 11 |
|
12 |
| -describe('no protractor at all', function() { |
13 |
| - it('should still do normal tests', function() { |
| 12 | +describe('no protractor at all', () => { |
| 13 | + it('should still do normal tests', () => { |
14 | 14 | expect(true).to.equal(true);
|
15 | 15 | });
|
16 | 16 | });
|
17 | 17 |
|
18 |
| -describe('protractor library', function() { |
19 |
| - it.skip('should be able to skip tests', function() { |
| 18 | +describe('protractor library', () => { |
| 19 | + it.skip('should be able to skip tests', () => { |
20 | 20 | expect(true).to.equal(false);
|
21 | 21 | });
|
22 | 22 |
|
23 |
| - it('should expose the correct global variables', function() { |
| 23 | + it('should expose the correct global variables', () => { |
24 | 24 | expect(protractor).to.exist;
|
25 | 25 | expect(browser).to.exist;
|
26 | 26 | expect(by).to.exist;
|
27 | 27 | expect(element).to.exist;
|
28 | 28 | expect($).to.exist;
|
29 | 29 | });
|
30 | 30 |
|
31 |
| - it('should wrap webdriver', function() { |
| 31 | + it('should wrap webdriver', async function() { |
32 | 32 | // Mocha will report the spec as slow if it goes over this time in ms.
|
33 | 33 | this.slow(6000);
|
34 |
| - browser.get('index.html'); |
| 34 | + |
| 35 | + await browser.get('index.html'); |
35 | 36 | expect(browser.getTitle()).to.eventually.equal('My AngularJS App');
|
36 | 37 | });
|
37 | 38 |
|
38 |
| - describe('with async tests', function() { |
39 |
| - var finished = false; |
| 39 | + describe('with async tests', () => { |
| 40 | + let finished = false; |
40 | 41 |
|
41 |
| - it('should wait for async operations to finish', function() { |
42 |
| - browser.get('index.html').then(function() { finished = true; }); |
| 42 | + it('should wait for async operations to finish', async() => { |
| 43 | + await browser.get('index.html'); |
| 44 | + finished = true; |
43 | 45 | });
|
44 | 46 |
|
45 |
| - after('verify mocha waited', function() { |
46 |
| - if(!finished) { throw new Error('Mocha did not wait for async!'); } |
| 47 | + after('verify mocha waited', () => { |
| 48 | + if(!finished) { |
| 49 | + throw new Error('Mocha did not wait for async!'); |
| 50 | + } |
47 | 51 | });
|
48 | 52 | });
|
49 | 53 | });
|
0 commit comments