I try to test this class
class Scraper {
async run() {
return await nightmare
.goto(this.url)
.wait('...')
.evaluate(()=>{...})
.end
}
}
And my test looks like this:
test('Scraper test', t => {
new Scraper().run().then(() => {
t.is('test', 'test')
})
})
Test fails:
Test finished without running any assertions
EDIT
repository on github: https://github.com/epyx25/test
test file: https://github.com/epyx25/test/blob/master/src/test/scraper/testScraper.test.js#L12
You need to return the promise. Assertion planning is not needed:
test('Scraper test', t => {
return new Scraper().run().then(() => {
t.is('test', 'test')
})
})
Or better still, using an async test:
test('Scraper test', async t => {
await new Scraper().run()
t.is('test', 'test')
})