3.0.0
Release overview
👾 Please report any bugs or regressions you encounter with this release!
- End of support for IE8 and earlier
- Improved ES6 support
- New executors API
- Configurable reporters
- New QUnit-compatible interface
- New TypeScript ambient declarations
- Test timeout improvements
- Test lifecycle improvements
- Bug fixes
Special thanks to @andyearnshaw, @apsdehal, @devpaul, @jason0x43, @kitsonk, @leohuber, @nicknisi, @plumlee, @sholladay, and @vladikoff for their code contributions!
Additional thanks to @Arnavion, @bartoszkaczorek, @devpaul, @JamesMGreene, @kitsonk, @mambocab, @mgingras, @nwhite89, @pocesar, @samplesizeofone, @sholladay, @stdavis, @treasonx, @vladikoff, @williamrjribeiro, and @wkeese for submitting tickets that were addressed in this release!
Backwards-incompatible changes
Here are the most common changes that need to be made when upgrading to Intern 3:
-
The new
basePathconfiguration option takes the place of the oldloader.baseUrlproperty. Nominally, this means that you’ll simply move a path fromloaderOptions.baseUrltobasePath.loaderOptions.baseUrlshould be unset (or changed to whatever you want, now that it can be set independently!). If you never usedbaseUrlbefore, you don’t need to change anything. -
The built-in reporters should now be addressed using an upper-case first letter (e.g.
'Console'instead of'console'). The test system will warn you about deprecated reporter naming. -
The following configuration options have been renamed for clarity and consistency:
useLoader→loadersloader→loaderOptions
The test system will warn you about deprecated configuration option usage.
-
excludeInstrumentationpaths are now normalized to always use forward-slashes regardless of OS. Windows users using backslashes with this configuration option should update to use forward-slashes. -
For users upgrading from Geezer, calls to
this.get('remote')need to change tothis.remote. Any other calls to get Test or Suite properties also change similarly (fromthis.get('property')to simplythis.property). -
The paths to loaders in
loadersare now relative to thebasePathinstead of relative to the default working directory, so these paths may need to be adjusted slightly if you are using a custom loader.
Other known backwards-incompatible changes that won’t affect most users:
- The future is now, so IE8 and earlier are no longer officially supported as targets for unit testing. Intern 2 will continue to work if you need to run tests in these dead browsers, or you may engage SitePen to create intern-geezer 3.
- Individual test timeouts are now inherited from their parent suites instead of from
Test.prototype.timeout. If you were setting a global test timeout usingTest.prototype.timeout, usedefaultTimeoutinstead. - In order to allow Test runs to be repeatable, the
skippedproperty of a test can no longer be set before callingtest.runto prevent the test function from running. - Using the
intern!objectinterface, a test named “timeout” is no longer allowed. (Thetimeoutproperty has changed to define the timeout for all tests in a given test suite.) beforeEachandafterEachare no longer executed when a test is skipped withgrep. If you were relying on these functions being executed for skipped tests, please open a ticket.- Intern now uses a Promises/A+-compatible Promises implementation. If you were using Intern Promises directly and relied on the immediate invocation properties of resolved promises (this would be unusual), some of your code may execute in the wrong order. Promise callbacks are now guaranteed to execute on the next turn through the event loop.
- The Deferred object created by
this.asyncno longer hasthen,otherwise, oralwaysmethods; if you were using these methods, usedfd.promise.then,dfd.promise.catch, anddfd.promise.finally, respectively. - The Promise object created by
this.asyncno longer hasotherwiseoralwaysmethods; if you were accessing these methods, usecatchandfinally, respectively. Note that the behaviour offinallyis different from the behaviour ofalways: if the callback passed tofinallydoes not throw or return a value other thanundefined, the value will be passed through from the earlier promise. This matches more closely the wayfinallyworks in JavaScript itself. - The order of certain reporter events is now slightly different. For example, the
tunnelStartevent is not emitted until after the tunnel is successfully started, whereas in Intern 2 it was emitted before attempting to start the tunnel. - There is no longer a main suite called 'main'. Instead, there are one or more root suites whose names are
null. Reporters that were using/suite/endand testing onsuite.nameto find the root suite can typically be switched to use therunEndevent instead and look atexecutor.suitesfor the list of root suites. - The name of the remote environment from the
environmentsconfiguration property is now added to all test IDs when running the test runner (e.g. 'internet explorer 11 on WIN8.1'). - The JUnit reporter outputs to stdout by default. Use
{ id: 'JUnit', filename: 'report.xml' }to restore the previous behaviour. - The following configuration options have been removed:
autoRun→ return a Promise from abeforefunction in the configuration file
suite.environmentTypehas been removed; usesuite.remote.environmentTypeinstead.- Various properties have been moved away from the
intern/mainobject:config→executor.configmaxConcurrency→executor.config.maxConcurrencysuites→executor.suitestunnel→executor.tunnelgrep→executor.config.grep
- Any custom interface that registers suites directly with Intern needs to change to use
intern.executor.registerinstead ofintern.suites. Read the custom interfaces documentation for more information.
New features
- Reporters have a new API and are now more testable and configurable. Custom reporters using the old style continue to be supported until 4.0, but are deprecated and should be updated to conform to the new API. (#141, #257)
- Test “executors” have been introduced. These objects represent the entire Intern testing lifecycle. They can be loaded and called directly from other JavaScript programs, and are customisable so you can make Intern conform to your preferred testing workflow. (#373)
- A new QUnit-compatible test interface has been introduced. Got a bunch of tests already written in QUnit? Just wrap them with
define([ 'intern!qunit' ], function (QUnit) { /* tests go here */ });and you’re done! (#383) - Intern is now bundled with TypeScript definitions for better integration with TypeScript. (Note: due to limitations in TypeScript not all APIs are currently modelled.) (#318)
Enhancements
- The reporter used when the test runner executes unit tests in browsers (the WebDriver reporter) can now be configured with the new
runnerClientReporterconfiguration option. The new configuration options allow the normal HTML rendering to be prevented, and to allow other reporters running on the server to pause unit test execution (for e.g. screenshots). (e4b56b9) - Early test run failures are now reported visibly, so you don’t have to guess why your tests aren’t loading. (#230)
- Reporters can now pause test execution by returning promises. This allows reporters to interact with the environment to collect any extra information that needs to be reported before/after tests, like screenshots. (#368)
- Suite lifecycle methods
beforeEachandafterEachare now passed a reference to the current Test object. (#342, #369, 0450494) - The loader’s
baseUrlproperty is now separate from the test system’sbasePathproperty, so you can specify the base path for your test environment independently from the loader’sbaseUrlconfiguration. (#249) - Instrumented code is cached by the instrumenting proxy during test runs, improving test runner performance. (ab03be3)
- The new
defaultTimeoutconfiguration property specifies the default timeout for all tests in a test run. (#350) - The new
Test#restartTimeoutmethod allows a timeout limit to be restarted on long-running asynchronous tests. (33555ad) - Timeouts can now be configured on a per-suite basis by setting
this.timeoutinside a suite function (using TDD/BDD interfaces), or by setting thetimeoutproperty on a suite object (Object interface). (#342, #350) - TypeScript ambient declarations are now bundled with Intern. (#318)
beforeEachandafterEachare no longer executed when a test is skipped withgrep. (#298)- Cancelling a test run with SIGINT (ctrl+c) now cleans everything up before quitting.
- The test system will automatically terminate after a test run has completed, even if there are outstanding open sockets/timeouts created by defective code, instead of hanging forever waiting for the sockets/timeouts to finish.
excludeInstrumentationpaths are now normalized to always use forward-slashes regardless of OS. (ab776f5)- Chai is updated to 3.0.0. (#387, #400)
NODE_ENVcan now be passed from a Grunt file. (#343)- Code instrumentation can be completely disabled by setting
excludeInstrumentationtotrue. (1dc4b55) excludeInstrumentationpaths are now normalized to always use forward-slashes regardless of OS. Windows users using backslashes with this configuration option should update to use forward-slashes. (#360, #378)- Remote environments can now be left open only when a test fails by setting
leaveRemoteOpentofail. (#398) - The test runner will now automatically retry creating a remote session if it fails the first time. The number of retry attempts is configurable with the
environmentRetriesconfiguration option. (e67cc6b) - All configuration options can now be specified from the command-line. (#338)
- The code coverage global variable can now be configured using the
coverageVariableoption. (#329) - The Runner reporter has been enhanced with more colour and more output during testing. (6e80e01)
this.remotenow includes findDisplayed methods, which let you find elements that both exist and are visible/interactive. (leadfoot-1.6.0)- Leadfoot feature detection can be disabled by adding
fixSessionCapabilities: falseto environment capabilities. This is needed when running tests on native apps, which don’t support JavaScript execution used by the feature detection code. (leadfoot-1.3.0) - Local files are now transparently uploaded and used when typing a path to a local file using the
typecommand. (leadfoot-1.5.0) - Stack traces for functional test commands are now a more sane length. (leadfoot-1.5.0)
- Istanbul is updated to 0.3.17, which improves support for new ES6 language syntax. (#445, #446)
- Istanbul output is now coloured when run through the Grunt task. (#422)
- The Runner reporter now shows how many tests were skipped on a per-environment basis. (#421, #430)
Bug fixes
- The list of suites from the configuration file are no longer passed to browsers in the query string during remote test runs. (#379)
- Non-cancellable Promises can now be used with test timeouts. (#337)
- Source map line numbers should now be more correct (1) on Windows, (2) for source maps that are referenced inside subdirectories, (3) on stack frames with anonymous functions. (#332, #339)
- The JUnit reporter no longer duplicates test results. (#312, #365)
dfd.rejectOnErroranddfd.callbacknow correctly return the value from the underlying callback. (#331, db4c82f)- Specifying a default star loader map no longer breaks the test system. (#348, #351)
- Exotic error objects no longer crash the system when retrieving the error message. (#399)
- The Pretty reporter will no longer hang when a fatal error occurs. (#319)
- The Grunt task will no longer duplicate error output from the test system on failure. (#260)
- Boolean arguments are now passed correctly from Grunt to Intern. (1d1d536)
- Sauce Labs and TestingBot tunnels now start correctly on Node 0.12. (digdug-1.3.0, digdug-1.3.1)
- The TeamCity reporter now correctly groups sessions. (#407, #447)
Install from npm
cd /my/project/root
npm install intern --save-dev