avajs / gulp-ava Goto Github PK
View Code? Open in Web Editor NEWRun AVA tests
Home Page: https://ava.li
License: MIT License
Run AVA tests
Home Page: https://ava.li
License: MIT License
Possible via options?
I have following gulp tasks
const test = (files) => {
return gulp.src(files)
.pipe(ava())
}
gulp.task('test', () => test('./test/**/*.js'))
gulp.task('test:watch', () => gulp.watch(['./test/**/*.js', './app/scripts/**/*.js'], ['test']))
When I start test:watch task, change some file, some tests fail and watch will keep watching. When all tests pass and I change some file, nothing is happening
cmd output
gulp test:watch
[11:48:00] Using gulpfile C:\test\gulpfile.js
[11:48:00] Starting 'test:watch'...
[11:48:00] Finished 'test:watch' after 26 ms
# I change file, test task starts
[11:48:04] Starting 'test'...
[11:48:07] 'test' errored after 2.51 s
[11:48:07] Error in plugin 'gulp-ava'
Message:
4 passed 1 failed
1. add cell
t.same(game.addCell([], 0, 1), [[0, 0]])
|
[#Array#]
AssertionError: [ [ 0, 1 ] ] === [ [ 0, 0 ] ]
Test.fn (test/world.test.js:27:5)
# I fix failing test, test task starts
[11:48:12] Starting 'test'...
[11:48:15] gulp-ava:
5 passed
# All tests passed, I change file again and nothing is happening
OS: win10
Successful run:
[23:59:11] Using gulpfile ~/git/flowcrypt-api/test/gulpfile.js
[23:59:11] Starting 'default'...
[23:59:11] Starting 'buildTest'...
[23:59:14] Finished 'buildTest' after 3.41 s
[23:59:14] Starting 'runTest'...
✔ simple test fail
✔ simple test pass
2 tests passed
[23:59:15] Finished 'runTest' after 1.2 s
[23:59:15] Finished 'default' after 4.61 s
Unsuccessful run:
[23:56:23] Using gulpfile ~/git/flowcrypt-api/test/gulpfile.js
[23:56:23] Starting 'default'...
[23:56:23] Starting 'buildTest'...
[23:56:26] Finished 'buildTest' after 2.88 s
[23:56:26] Starting 'runTest'...
✖ simple test fail Rejected promise returned by test
✔ simple test pass
1 test failed
simple test fail
/home/luke/git/flowcrypt-api/test/build/test.ts:8
Rejected promise returned by test. Reason:
AssertionError {
actual: 1,
expected: 5,
message: 'expected 1 to equal 5',
showDiff: true,
}
[23:56:27] 'runTest' errored after 866 ms
[23:56:27] Error in plugin 'gulp-ava'
Message:
Command failed: /usr/local/bin/node /home/luke/git/flowcrypt-api/test/node_modules/gulp-ava/node_modules/ava/cli.js /home/luke/git/flowcrypt-api/test/build/test.js --color --no-silent --verbose
✖ simple test fail Rejected promise returned by test
✔ simple test pass
1 test failed
simple test fail
/home/luke/git/flowcrypt-api/test/build/test.ts:8
Rejected promise returned by test. Reason:
AssertionError {
actual: 1,
expected: 5,
message: 'expected 1 to equal 5',
showDiff: true,
}
Details:
code: 1
stdout:
stderr:
✖ simple test fail Rejected promise returned by test
✔ simple test pass
1 test failed
simple test fail
/home/luke/git/flowcrypt-api/test/build/test.ts:8
Rejected promise returned by test. Reason:
AssertionError {
actual: 1,
expected: 5,
message: 'expected 1 to equal 5',
showDiff: true,
}
failed: true
signal: null
cmd: /usr/local/bin/node /home/luke/git/flowcrypt-api/test/node_modules/gulp-ava/node_modules/ava/cli.js /home/luke/git/flowcrypt-api/test/build/test.js --color --no-silent --verbose
timedOut: false
killed: false
domainEmitter: [object Object]
domain: [object Object]
domainThrown: false
[23:56:27] 'default' errored after 3.76 s
Notice it will print out the error 3 times. Any way to improve this?
After updating to [email protected], I can't generate report after testing.
[email protected] works correctly.
...
"nyc": {
"include": [
"dist/src/**/*.js"
],
"exclude": [
"dist/src/public/**/*.js",
"dist/**/*.spec.js"
],
"extensions": [
".ts"
],
"cache": true,
"all": true,
"check-coverage": false
}
...
gulp.task("test", ["pretest"], () => {
return gulp.src("dist/test/**/*.spec.js")
.pipe(ava({
verbose: true,
failFast: false,
powerAssert: true,
nyc: true,
}));
});
Error messages are not being displayed when running AVA via gulp-ava.
Node: 0.10.44
NPM: 2.15.0
AVA: ^0.15.2
Gulp AVA: ^0.12.0
Gulp task is setup exactly as example in README, but using glob instead.
return gulp.src('./test-node/**/*.js')
.pipe(ava());
Sample Test
test('initial registration of correct GET methods on server', t => {
// Assert
t.deepEqual(['/'], ['/logout', '/', '/harness']);
// have also tried t.deepEqual(['/'], ['/logout', '/', '/harness'], 'message here');
});
output from gulp task
[11:23:40] Using gulpfile ~/Documents/WorkingEnvironment/ActiveAudiences/gulpfile.js
[11:23:40] Starting 'test'...
[11:23:40] Starting 'tests:node'...
/Users/avernacchia/Documents/WorkingEnvironment/ActiveAudiences/node_modules/gulp-ava/node_modules/gulp-util/lib/PluginError.js:73
if (!this.message) throw new Error('Missing error message');
^
Error: Missing error message
at new PluginError (/Users/avernacchia/Documents/WorkingEnvironment/ActiveAudiences/node_modules/gulp-ava/node_modules/gulp-util/lib/PluginError.js:73:28)
at DestroyableTransform.<anonymous> (/Users/avernacchia/Documents/WorkingEnvironment/ActiveAudiences/node_modules/gulp-ava/index.js:29:24)
at ChildProcess.exithandler (child_process.js:662:7)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Socket.<anonymous> (child_process.js:979:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
output from node ./node_modules/ava/cli.js
> node ./node_modules/ava/cli.js --watch
1 failed [11:26:44]
1. index › initial registration of correct GET methods on server
t.deepEqual(['/'], ['/logout', '/', '/harness'])
Test.fn (index.js:24:5)
handleMessage (child_process.js:322:10)
Pipe.channel.onread (child_process.js:349:11)
When using execFile to execute test,
That is the error I get when console.logging the stderr.
I suggest to use spawn instead of execFile , because of the bufferLimitation of exec vs spawn.
There is still a bug in spawn buffer, in the case where the output is not captured, which is not our case : nodejs/node#4236
I will probably give you a PR for this fix.
Good job btw :)
{ Error: stderr maxBuffer exceeded
at Socket.onChildStderr (child_process.js:282:14)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at Pipe.onread (net.js:554:20)
Would it be useful to integrate nyc into this?
P.S: If yes, would be interested to do a PR (yet to read the source of gulp-ava
though).
Windows 8. node v5.3.0. gulp v3.9.0.
If the test file contains no tests or an assertion fails:
Error: Missing error message at new PluginError (x:\Web\solitaire\node_modules\gulp-util\lib\PluginError.js:73:28)
Otherwise:
[21:45:31] gulp-ava:
Relates to: avajs/ava#143
If I explicitly use gulp-ava 0.2.x with ava 0.2.x, then everything works perfectly.
But if I use gulp-ava 0.2.x with ava 0.3.0, then it throws an error "process.send is not a function".
Hi
ava
binary placed on (project root)/node_modules/.bin/ava
on npm3.
var BIN = path.join(__dirname, 'node_modules', '.bin', 'ava');
raises ENOENT error. How to fix this?
Thanks
It's very useful to add option for setting reporters,such as tap-min,tap-spec ...
The original ava output gives to much trivial message.
gulp-util
has been deprecated and it causes a warning when running npm install
:
https://www.npmjs.com/package/gulp-util
$ node -v
v12.6.0
$ npm -v
6.9.0
There is a guide from gulpjs on how to remove this dependency:
https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
It seems, so far in gulp-ava, that the only method used from gulp-util
is PluginError
. Could we remove gulp-util
as a dependency and replace it with plugin-error
(https://www.npmjs.com/package/plugin-error) as indicated by the guide above?
While using Gulp 4.0 to write tests like this:
gulp.task('someTests', function () {
gulp.src(filePath).pipe(ava({verbose: true}));
});
I got the error:
The following tasks did not complete: xxxx
Did you forget to signal async completion?
It turns out in 4.0:
Gulp tasks are asynchronous and Gulp uses async-done to wait for the task's completion. Tasks are called with a callback parameter to call to signal completion. Alternatively, Task can return a stream, a promise, a child process or a RxJS observable to signal the end of the task.
Warning: Sync tasks are not supported and your function will never complete if the one of the above strategies is not used to signal completion. However, thrown errors will be caught by Gulp.
And there is a more detailed explanation on SO.
I picked the callback option from that SO answer:
- Call the callback function
This is probably the easiest way for your use case: gulp automatically passes a callback function to your task as its first argument. Just call that function when you're done:
gulp.task('message', function(done) {
console.log("HTTP Server Started");
done();
});
But when I tried to do this:
gulp.task('someTests', function (done) {
gulp.src(filePath).pipe(ava({ verbose: true })).on('end', function () {
done();
});
});
The done function was never being called. I tried several times under different settings of my test file and was not successful. I also put a console.log before the done call, it was never being called, either. So it seems there is no 'end' emitted by pipe(ava({ verbose: true })). But I did not find a way to put a callback into the gulp-ava call.
Is it just me? Or I was doing it the wrong way?
Thanks in advance,
Liwei
I get the following error in Gulp 4:
The following tasks did not complete: ava
So I guess it returns a stream that never ends, even when the process dies?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.