Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clinical-meteor/meteor-phantomjs-tests
meteor-phantomjs-tests
https://github.com/clinical-meteor/meteor-phantomjs-tests
Last synced: about 1 month ago
JSON representation
meteor-phantomjs-tests
- Host: GitHub
- URL: https://github.com/clinical-meteor/meteor-phantomjs-tests
- Owner: clinical-meteor
- License: mit
- Created: 2016-12-04T03:33:45.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-04T03:43:01.000Z (about 8 years ago)
- Last Synced: 2024-10-29T21:06:27.498Z (2 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dispatch:phantomjs-tests
This package exports a `startPhantom` function for server code, which runs your client tests within a PhantomJS page. Meteor test driver packages can depend on this package. See the example implementation here: https://github.com/DispatchMe/meteor-mocha-phantomjs
## Usage
In your test driver package `package.js` file, add
```js
api.use('dispatch:[email protected]', 'server');
```Then in your server code, do something similar to this:
```js
import { startPhantom } from 'meteor/dispatch:phantomjs-tests';function start() {
startPhantom({
stdout(data) {
console.log(data.toString());
},
stderr(data) {
console.log(data.toString());
},
done(failureCount) {
// Your code to run when client tests are done running
},
});
}export { start };
```And in your client code, you need to set some properties on `window` so that the PhantomJS script knows what is happening:
```js
// Run the client tests. Meteor calls the `runTests` function exported by
// the driver package on the client.
function runTests() {
// These `window` properties are all used by the phantomjs script to
// know what is happening.
window.testsAreRunning = true;
mocha.run((failures) => {
window.testsAreRunning = false;
window.testFailures = failures;
window.testsDone = true;
});
}export { runTests };
```