* 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
clean-yaml-object is the error serialization tool used by node-tap.
It has some nice benefits over serailze-error including better stringification of functions and buffers.
More importantly, the shared code will help keep our tap output consistent with that of node-tap.
Test workers keep track of test dependencies for all registered file extensions.
These are sent back to the Api as part of the 'teardown' event, ensuring they're
captured irrespective of whether tests passed.
The watcher rejects any dependencies that are not source files, matching how
Chokidar watches for source file modifications. It maintains a list of source
dependencies for each test file.
The watcher will find the test files that depend on modified source files and
rerun those (along with any other modified test files). If any modified source
files cannot be mapped to test files all tests are rerun. This is necessary
because only `require()` dependencies are tracked, not file access.
fork.js sends the teardown command when uncaught exceptions occur, if there are
no tests, and when results are received. However the results message is sent
from the worker when all tests have run. This means teardown can be sent more
than once.
This prevents interference between the mini logger and child processes that use `console.log`. The mini reporter previously used logUpdate which deletes lines previously written with the logUpdate API before writing a new one. This caused problems if lines from console.log were written inbetween logUpdate calls. It would delete the users log messages instead of the test status line. To fix this, we store the last written last log line, clear it, write the users log output, then restore the last log line. This keeps the miniReporter output always at the bottom of the log output.
It also fixes an incorrect use of the `child_process` API. We were using the `stdio` option for `child_process.fork`, but that option is ignored (it is honored for just about every other method in that API). See: 7b355c5bb3/lib/child_process.js (L49-L50)
It also adds a set of visual tests which can be run via `npm run visual`. They must be run manually, and should be run as part of our pre-release process.
Instead depend on npm to dedupe. This is better as we will no longer fail if the user has Babel 6 and we Babel 5, and npm just won't dedupe. Same situation in the future when we're on Babel 6, but the user is still on Babel 5.
There are two possible errors that can result in no test data being
received.
1. The user never imports `ava` in their test file.
2. The user has not written any tests in the file yet.
We treat both as errors, but were handling them differently.
Most problematic, one caused the promise to resolve, the other
caused the promise to reject.
I want to start focusing on getting our require times down,
both in the main thread and forked tests.
This adds `time-require` support directly to the CLI to assist in that.
This is especially important for forked test processes, where I currently
have to manually add a line of code each time I want to test an optimization.
I don't think this should be a publicly documented move. I think we want
the freedom to remove this once we are happy with performance.
I have placed comments above all `time-require` references, indicating
it is for internal use only. Users have been given fair warning against
relying on its inclusion long term.
Usage:
```sh
$ DEBUG=ava ./cli.js test/fixture/es2015.js --sorted
```
`--sorted` is optional. It sorts the requires from most expensive to least. The default is sequential sorting.
The output will display multiple `time-require` reports.
One for each forked process, and the last one for the main thread.
When using source maps to compute stack traces, if the source map is not in
memory, fall back to source-map-support's default retrieval function which can
get it from a source map pragma in the source file.
This means any dependency that has such pragmas (and the required map files) has
its errors mapped correctly, e.g. the code under test, or third-party
dependencies that ship with source maps.
This should also work for inline source maps, though no test case was included.
This adds basic source map support. Since transpilation of dependencies
is not merged yet, the `sourceMapCache` object and lookup is a little
premature (since we will only ever have one file that we can apply
apply source maps to).
add small delay on exit from babel
(cherry picked from commit 11961f7)
if AVA is not required in a test, throw an error instead of process.exit
only extend timeout if env.AVA_APPVEYOR is set, so we only slow down
in our tests.