cloudfour/lighthouse-parade

Add test for error message when no pages are found

calebeby opened this issue · 7 comments

#30 (comment)

import { scan } from './scan-task'
test('Displays useful error if no pages are found while crawling', () => {
  const result = await scan('https://nonexistent-website.com')
  expect(result.error).toMatch(/No pages were found for this site/)
})

We can get away with it for this test, but it's hacky for tests to make live requests. Also very slow. Sooner than later we need to figure out a way to do this the right way. So maybe we take our time with that future issue when we get there.

@calebeby how do you feel about taking this on?

Sounds good, I'll start on this soon.

Cool. Take your time with this. I see this one as much about figuring out the underlying test strategy for mocking/stubbing live lighthouse requests.

@emersonthis If I understand correctly we'll only need to stub the requests from the crawler, not from lighthouse, right?

For this specific test, you're right. I'm trying to find excuses to start thinking/planning for how to run tests "around" lighthouse, too. Maybe here isn't the right place for that...

I think we may end up needing a "lighthouse replacement" that we can use for testing in place of lighthouse, but I don't think this is the right issue for that either

I'll create a new issue...