0.0.5 • Published 7 years ago

nightmare-jasmine v0.0.5

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
7 years ago

nightmare-jasmine Build Status npm apache2

Jasmine wrapper for Nightmare

Installation

npm install --save-dev nightmare-jasmine

Usage

import { Context as BaseContext, run } from 'nightmare-jasmine'

run({
  params: {
    username: 'foo'
  },
  specFiles: [
    './hooks/beforeAll.js',
    './hooks/beforeEach.js',
    './specs/*.js'
  ]
})

API

run(options: Options)
  .then(() => console.log('Success!'))
  .catch(e => console.error('Error!', e))

Options:

NameTypeRequired?Description
baseDirstringNoDirectory that spec files should be resolved relative to
isDebugbooleanNoShow browser?
paramsObjectNoAdditional params to pass to tests
specFilesstring[]YesGlob array of spec files

Example spec

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)