0

Every tutorial I have seen for mocha-phantomjs shows having a test harness html file, and a separate javascript file that gets included.

Is this the correct way to do this for each test? I want to create a separate test for each page in my website, but it seems like overkill/crazy to duplicate an html file for every test case.

Granged, this is my first time trying to use mocha-phantomjs, but still, it seems really odd to create an html file and a js for every test case.

What is the standard for doing this sort of thing? I have been googling for about an hour now and can't find any good examples.

FlimboyJim
  • 69
  • 6

1 Answers1

0

I know it seems weird, but... yes.

You need fixture (or harness) files in the "/test" directory. By default, Mocha looks in this directory for filenames with a .html extension, starting with test.html.

Make sure to include the script (and css) tags for 1) mocha, 2) chai (or whatever other assertion library you want), 3) and your specific test suites.

Personally, I've found it helps to use it with a modular bootloader like RequireJS. That way all your fixture files can point to a single configuration file: less maintenance.

Tom Cornyn
  • 16
  • 3