Intern - Debugging
// Intern - Debugging: Debugging unit tests is simple and straightforward: 1. Open the test suite in the browser: http://localhost/my-project/node_modules/intern/client.html?config=tests/intern 2. Use your browser's debugging tools to inspect and debug your unit test code. Debugging functional tests is more involved. Intern uses WebDriver, which use HTTP to communicate with the WebDriver / Selenium server. We can use a debugging proxy such as Fiddler to log all the HTTP requests between our computer, Intern, and the WebDriver server. If we manually starts the WebDriver server, we can perhaps configure it to log all the requests that it receives, as well as the response that it sent back to a file. We can configure Intern to use this specific WebDriver server. I wish that Intern has a configuration flag that allow us to control the its verbosity. Each command should log its name, parameters. I primarily want to know the selector of the element that it is interacting with, and whether the WebDriver server was able to find that element. Knowing this information, we can look at the page object to determine the name of the element, and looking at the test case, we can see the step that is failing. Alternatively, because our test cases are run in a Node environment, we can debug out test cases by using node-inspector. We will need to use a Blink-based browser such as Chrome to debug. node-inspector provides the node-debug command which is a drop-in replacement for node. We will have to launch the Intern's "test runner" manually, rather than invoking intern-runner: node-debug node_modules/intern/runner config=myPackage/test/intern This will launch the specified script (node_modules/intern/runner.js) in Node.js with debugging enabled and open the browser UI (in your default browser). If Chrome is not our default browser, we will have to copy and paste this URL into the Chrome browser's address bar and hit the Enter key. At this point we should see Chrome’s debugging UI. We can press F8 to continue script execution until your debugger statement is reached. From this point we can debug as usual. In this environment, we only have access to inspect and debug the test module, not the AUT. This UI is provided by node-inspector. The Chrome's developer tool is not actually open. Once we are happy with our test suites, we can run them across a variety of browsers and platforms using Selenium Grid, BrowserStack, Sauce Labs, or TestingBot. If we encounter issues with Sauce Labs, Sauce Connect creates a log file (sauce_connect.log) in the working directory that you launch Intern from. You can also find more troubleshooting information in the Sauce Connect documentation.
page revision: 3, last edited: 11 Feb 2017 04:03