Running tests

There are quite few ways to run tests. Using a web browser, a command-line tool will open the web browser and close it after the test execution is completed. We can also run tests using standalone JavaScript environments.

Web browser

Disable the pop-up blocker and open tests/todo_test.html in the browser. The test will open the Todo application and run the test case against it. After this, you should be able to see something similar to the following screenshot:

Web browser

Selenium

Run the following command from the Todo app directory:

$ ./js funcunit/run selenium todo/tests/todo_test.html

This command will open Firefox, run exactly the same test as in the web browser example, close the browser, and print the results on a command line.

PhantomJS

A much faster solution is running test using PhantomJS, because it doesn't launch the web browser.

Execute following command to run the test:

$ ./js funcunit/run phantomjs todo/tests/todo_test.html

The preceding command will run the test in a PhantomJS environment, so it won't open any web browser as it did in the previous case. But, it will run tests inside the WebKit wrapper.

The command-line output should be similar to the following:

Opening file:///Users/wbednarski/Sites/DEV/JMVC/Todo/todo/tests/todo_test.html
starting steal.browser.phantomjs
steal.js INFO: Opening //todo/todo.html
steal.js INFO: using a dynamic fixture for GET /todos
steal.js INFO: ajax request to todos.ejs, no fixture found
steal.js INFO: ajax request to todos.ejs, no fixture found
default route

Todo app
 page has #todos placeholder
  [x] The #todo is child of the body

Time: 3 seconds, Memory: 81.06 MB

OK (1 tests, 0 assertions)

EnvJS

Another way to run tests is to use EnvJS-simulated browser environments written in JavaScript.

EnvJS can only be used to run unit tests, because it doesn't accurately implement event simulation.

Run the test by executing the following command:

$ ./js funcunit/run envjs todo/tests/todo_test.html
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.182.62