This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runner): add beta support for using mocha as your test framework
This change adds limited support for using mocha as the test framework instead of jasmine. Make the switch by using `--framework=mocha` on the command line or adding `framework: 'mocha'` to the config. Tests will be run using the BDD interface. The interface is adapted so that tests run asynchronously without needing to call `done()`. Note that there is currently no support for an assertion framework, so you will need to require whichever assertion framework you prefer. This means there is no adapter to make the assertions unwrap promises, so you will need to resolve promises yourself and run the assertions afterwards.
- Loading branch information
Showing
10 changed files
with
173 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* This example shows how to use the protractor library in a Mocha test. | ||
* | ||
* Run this test with: | ||
* protractor example/mocha/mochaConf.js | ||
*/ | ||
|
||
// Note that there is nothing adapting expect.js to understand promises, | ||
// so we may only use it once promises have been resolved. | ||
var expect = require('expect.js'); | ||
|
||
describe('angularjs.org homepage', function() { | ||
this.timeout(80000); | ||
|
||
it('should greet using binding', function() { | ||
browser.get('http://www.angularjs.org'); | ||
|
||
element(by.input('yourName')).sendKeys('Julie'); | ||
|
||
element(by.binding('{{yourName}}')). | ||
getText().then(function(text) { | ||
expect(text).to.eql('Hello Julie!'); | ||
}); | ||
}); | ||
|
||
it('should list todos', function() { | ||
browser.get('http://www.angularjs.org'); | ||
|
||
var todo = element(by.repeater('todo in todos').row(1)); | ||
|
||
todo.getText().then(function(text) { | ||
expect(text).to.eql('build an angular app'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// An example configuration file. | ||
exports.config = { | ||
// Do not start a Selenium Standalone sever - only run this using chrome. | ||
chromeOnly: true, | ||
chromeDriver: '../../selenium/chromedriver', | ||
|
||
framework: 'mocha', | ||
|
||
// Capabilities to be passed to the webdriver instance. | ||
capabilities: { | ||
'browserName': 'chrome' | ||
}, | ||
|
||
// Spec patterns are relative to the current working directly when | ||
// protractor is called. | ||
specs: ['example_spec.js'], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var expect = require('expect.js'); | ||
|
||
describe('no protractor at all', function() { | ||
it('should still do normal tests', function() { | ||
expect(true).to.eql(true); | ||
}); | ||
}); | ||
|
||
describe('protractor library', function() { | ||
it('should expose the correct global variables', function() { | ||
expect(protractor).not.to.be(undefined); | ||
expect(browser).not.to.be(undefined); | ||
expect(by).not.to.be(undefined); | ||
expect(element).not.to.be(undefined); | ||
expect($).not.to.be(undefined); | ||
}); | ||
|
||
it('should wrap webdriver', function() { | ||
browser.get('index.html'); | ||
browser.getTitle().then(function(text) { | ||
expect(text).to.eql('My AngularJS App'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// A small suite to make sure the mocha frameowork works. | ||
exports.config = { | ||
seleniumAddress: 'http://localhost:4444/wd/hub', | ||
|
||
framework: 'mocha', | ||
|
||
// Spec patterns are relative to this directory. | ||
specs: [ | ||
'mocha/*_spec.js' | ||
], | ||
|
||
capabilities: { | ||
'browserName': 'chrome' | ||
}, | ||
|
||
baseUrl: 'http://localhost:8000', | ||
|
||
params: { | ||
login: { | ||
user: 'Jane', | ||
password: '1234' | ||
} | ||
} | ||
}; |