Fixes#699. The watcher tracks how many failures (actual failures, but also
rejections and uncaught exceptions) occurred for each test file. After each run,
if there are failures from files that were not rerun, the count is added to the
logger output.
Sometimes the API sends exceptions to RunStatus. Ensure the file path for those
exceptions is relative, just like the exceptions coming from the fork emitter.
If the exception doesn't apply to any specific file, ensure the `file` is
undefined. I haven't bothered adding tests for this though.
Since #713 the API no longer emits 'dependencies' events. These are emitted
instead by the RunStatus, which can be obtained by listening to the 'test-run'
event on the API.
The watcher tests use a mocked API object which wasn't updated to reflect these
changes. Consequently dependency tracking was broken since #713 was merged.
This commit fixes the watcher and the corresponding tests. I've also added an
integration test which does not rely on mocking, helping us detect breakage
sooner.
* display current time when mini & verbose reporters finish
I'm using toLocaleTimeString() which works even back to Node.js 0.10. Forcing a
24-hour clock because we're geeks.
* watcher: restart logger on subsequent runs
The CLI starts the logger so the watcher shouldn't reset it on its first run.
Restart the logger after resetting, this allows the mini reporter to render its
spinner.
* better api.run stub in watcher test
Return an object for the runStatus, add assertions to verify this object is
passed to logger.finish()
* assert that r/rs reruns all tests
* clear mini reporter in watch mode
Clear the mini reporter unless the previous run had failures, or "r\n" was
entered on stdin.
* consistent empty lines in finish output
Always print two empty lines before each error/rejection/exception when the mini
and verbose reporters finish. Remove trailing whitespace from stack traces.
Always print an empty line after the finish output.
Add a test helper to more easily compare line output, with useful debug
information. At the moment this new helper is only used for failing tests.
* print line if reporter was not be cleared
Watch mode won't clear the mini reporter if there were errors, or "r\n" was
entered on stdin. The verbose reporter can't be cleared at all. To improve the
separation between multiple test runs, write a horizontal line when starting a
new test run and the reporter was not cleared.
* remove debug output from cli test
* watcher: correctly test if source is in the cwd
Make sure the path starts with ../ (after platform-specific slashes have been
corrected). Clarify existing test and add a case where the source starts with
two dots but is still in the current working directory.
* change handling of negated source patterns
Fixes#614. Allow negated source patterns to be specified without unsetting the
default negation patterns.
Allow source patterns to override the default negation patterns if they start
with one of the ignored directories.
* update watch mode docs
* Suggest `watch:test` as the npm script
* Document how to always enable watch mode using the ava section in package.json
* Recommend source patterns are configured through the ava section in package.json
* Suggest using the verbose reporter when debugging
* detect improper use of t.throws
Protects against a common misuse of t.throws (Like that seen in #739).
This required the creation of a custom babel plugin.
https://github.com/jamestalmage/babel-plugin-ava-throws-helper
* relative file path and colors
* protect against null/undefined in _setAssertError
* use babel-code-frame to do syntax highlighting on the Error
* require `babel-code-frame` inline. It has a sizable dependency graph
* remove middle section of message. It is redundant given code-frame
* further tests and add documentation.
* update readme.md
* extract files processing from api
* extract test-data class from API
* fix breakage from rebase
* pass testData to reporters in every method
* rename testData to runStatus
* runStatus.listenToTestRun => runStatus.observeFork
* rename test-data.js to run-status.js
* fix failing watcher test
The watcher used dir**/*.js as the recursive pattern when the initial pattern
matched a directory. This should be dir/**/*.js instead. Before this fix tests
were matched as sources, causing all tests to be rerun.