npm install --save-dev nightmare-jasmine
import { Context as BaseContext, run } from 'nightmare-jasmine'
run({
params: {
username: 'foo'
},
specFiles: [
'./hooks/beforeAll.js',
'./hooks/beforeEach.js',
'./specs/*.js'
]
})
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 |
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')
})
})
- 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 segment-boneyard/nightmare#863)