https://github.com/coatue-oss/nightmare-jasmine
Jasmine wrapper for Nightmare
https://github.com/coatue-oss/nightmare-jasmine
integration-testing jasmine nightmare unit-testing
Last synced: 3 months ago
JSON representation
Jasmine wrapper for Nightmare
- Host: GitHub
- URL: https://github.com/coatue-oss/nightmare-jasmine
- Owner: coatue-oss
- License: other
- Created: 2016-11-01T00:58:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-09T23:34:42.000Z (over 8 years ago)
- Last Synced: 2025-11-27T09:20:41.167Z (7 months ago)
- Topics: integration-testing, jasmine, nightmare, unit-testing
- Language: TypeScript
- Size: 27.3 KB
- Stars: 2
- Watchers: 10
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# nightmare-jasmine [![Build Status][build]](https://circleci.com/gh/coatue-oss/nightmare-jasmine) [![npm]](https://www.npmjs.com/package/nightmare-jasmine) [![apache2]](https://opensource.org/licenses/Apache-2.0)
> [Jasmine](https://github.com/jasmine/jasmine) wrapper for [Nightmare](https://github.com/segmentio/nightmare)
[build]: https://img.shields.io/circleci/project/coatue-oss/nightmare-jasmine.svg?branch=master&style=flat-square
[npm]: https://img.shields.io/npm/v/nightmare-jasmine.svg?style=flat-square
[apache2]: https://img.shields.io/npm/l/nightmare-jasmine.svg?style=flat-square
## Installation
```sh
npm install --save-dev nightmare-jasmine
```
## Usage
```ts
import { Context as BaseContext, run } from 'nightmare-jasmine'
run({
params: {
username: 'foo'
},
specFiles: [
'./hooks/beforeAll.js',
'./hooks/beforeEach.js',
'./specs/*.js'
]
})
```
## API
```ts
run(options: Options)
.then(() => console.log('Success!'))
.catch(e => console.error('Error!', e))
```
`Options`:
| Name | Type | Required? | Description |
|---------------------|-------------|-----------|------------------------------------|
| `baseDir` | `string` | No | Directory that spec files should be resolved relative to |
| `isDebug` | `boolean` | No | Show browser? |
| `params` | `Object` | No | Additional params to pass to tests |
| `specFiles` | `string[]` | Yes | Glob array of spec files |
## Example spec
```ts
describe('nightmare-jasmine', () => {
it('should route to #/foo', async function(this: Context) {
const url = await this.nightmare.wait('#myElement').evaluate(() => window.location.href)
expect(url).toBe('http://localhost:4000/#/foo')
})
})
```
## Usage notes
- If the process exits due to a Jasmine error, it will stay open for up to 30 secs (or whatever `nightmare.options.waitTimeout` is set to). This is because nightmare `.wait()` uses timeouts, which are not cleared when `.halt()` is called. (see https://github.com/segmentio/nightmare/issues/863)