bokuweb / karma-nightmare

⚡ A Karma plugin. Launcher for Nightmare
52 stars 5 forks source link

Help with nightmare.goto() #15

Open kof opened 7 years ago

kof commented 7 years ago

I'm using karma-nightmare version [0.4.8]

Description

I am struggling to understand how this should work with goto(url), meaning I need to open a url and then run nightmare actions on that page.

Any help is welcome.

Right now as soon as I require('nightmare'), I get errors like this

ERROR in ./~/nightmare/lib/actions.js
Module not found: Error: Can't resolve 'fs' in '/test/node_modules/nightmare/lib'
bokuweb commented 7 years ago

@kof Thanks for your report. Can you show me the minimum project to reproduce it?

kof commented 7 years ago

npm i && npm test

karma-nightmare-example.zip

All my code is basically this:

import expect from 'expect.js'

// Throws here.
import 'nightmare'

describe('test', () => {
  it('should pass', () => {
    expect(true).to.be(true)
  })
})
bokuweb commented 7 years ago

@kof Thanks!!

kof commented 7 years ago

Or actually its even simpler, can you make an example how to navigate to pages with nightmare.goto() from the tests?

bokuweb commented 7 years ago

You can not use nighhtmare.goto on karma. Because karma test is running on renderer pocess on Electron.If you want to use nightmare.goto(), please use nightmare and e.g mocha without karma.

kof commented 7 years ago

Yeah, but that would be cool.