mmonteleone / pavlov Goto Github PK
View Code? Open in Web Editor NEWBehavioral API over QUnit
Home Page: http://michaelmonteleone.net/projects/
Behavioral API over QUnit
Home Page: http://michaelmonteleone.net/projects/
I really like your library, but the one thing that hangs me up is async testing. The timeout wait you have works, but it can dramatically increase the time for the whole test suite to run.
There is another library like yours called SpecIt that has a asyncIt() method you can use instead of the it() which is just a small wrapper around QUnit's native asyncTest() method.
https://github.com/joshuaclayton/specit/blob/master/specit.js#L28
I think this addition would be very handy. Have you already considered this or are you thinking along a different lines?
Palov is super awesome for testing our jQuery plugin: http://ninjaui.com
Would you mind distributing via NPM? Should be straight forward, considering qunit is already available to use as a dependency through NPM.
We seek a Node.js package so we can automate our tests through a Jakefile and depend on the correct versions without having to maintain a copy in our own repo.
Does Pavlov work with QUnit 1.7.0pre?
It would be good to have the QUnit library included with Pavlov updated to the latest QUnit.
given([2,2,4], [5,2,7], [6,-4,2]).
it("can generate row data tests", function(a, b, c) {
assert(c).equals(a + b);
});
All good so far! but when we have a list of lists.... this doesn't seem to work...
given([[2,2,4], [5,2,7], [6,-4,2]]).
it("can generate row data tests", function(a, b, c) {
assert(c).equals(a + b);
});
Nor this:
(given.apply(null, [[2,2,4], [5,2,7], [6,-4,2]])).
it("can generate row data tests", function(a, b, c) {
assert(c).equals(a + b);
});
Am I doing something wrong here?
\n instead of \s in extendScope's regular expression
Hi there :)
I know this project is somewhat outdated, but somehow I like the spirit of it.
Was wondering how much it'd take to bring it to QUnit 2.x, or even 3, when it comes out?
After all, pavlov is still mentioned on QUnit's plugins page - as the second entry! Yet it relies on QUnit 1.9...
Main things I see:
extendScope
hack, which creates the illusion of global describe
, it
, assert
etc. has to go. That's pretty obvious to me, but I can explain why if you want me to (Metaprogramming as such is fine, but you can't do it like that, and not here).pavlov.specify
. The user then - we have ES6 now - just has to say once: pavlov.specify("foo", ({describe, before, after, it, assert}) => { ... })
. This would help minimize necessary changes to existing specs.I'd give it a try in a fork, if anyone's interested..?
Perhaps I don't quite understand how wait() (or the underlying start()/stop() engine), but I can't seem to get wait() to work more than once in a particular it() block. Any tests inside the function body of subsequent wait() calls are ignored (though the code does run).
Haven't quite tracked this all the way down, but I'm working on it, from what I can tell if you specify a feature without a test function before a given and without another feature without a test function after the given, it will produce an error something like this:
Died on test #1: Result of expression 'thisApi.assert' [undefined] is not an object. - {
"message": "Result of expression 'thisApi.assert' [undefined] is not an object.", "line": 344,
"sourceId": 5279531008, "sourceURL": "file:///Users/ericdelabar/Documents/Code/git-
repos/pavlov/pavlov.js", "expressionBeginOffset": 11237, "expressionCaretOffset": 11251,
"expressionEndOffset": 11256, "name": "TypeError" }
Since that sounds very confusing, see line 19:
If you move the code on line 19 to line 44 (after the final given) it works as expected. I'm going to try and tackle this one myself, so hopefully expect a pull request in a day or so...
I'm trying to tackle this one myself but I figured I'd post it in case anybody else is seeing the problem.
Hi Michael,
I have a modular javascript application that uses Require.JS and so far I've being writing tests as modules using QUnit without trouble. I'd like however to use Pavlovs instead and I assumed it would work similar to qunit tests but so far I had no success. The code below illustrates a qunit test written as a module:
define(['models/User2'], function(User) {
test( "Create valid user", function(){
var user = new User({username: 'eric', cellphone: '11-9999-8888', password: '123456', agreement: true});
ok(user.isValid(), 'created a valid user instance.');
});
});
In this code we load the module "models/User2" into the function param User, which makes the User model available during the tests. If I write a similar code with Pavlov the User variable becomes undefined.
define(['models/User2'], function(User) {
pavlov.specify("User Model spec", function(){
describe("User", function() {
var user;
given({username: 'eric', cellphone: '11-9999-8888', password: '123456', agreement: true}).
it('should create a valid user instance', function(data){
user = new User(data);
assert(user.isValid()).equals(true);
});
});
});
});
Is there a way to write Pavlovs as AMD modules?
Thanks in advance,
Eric
First of all, thanks for the awesome library and great JSTestDriver example!
I'm struggling to get my tests working because my project uses RequireJS for dependency management. My pavlov tests, themselves, also are RequireJS AMD modules, which in turn have dependencies on the modules under test.
I have one common main.js file which is shared between my normal index.html file that loads the UI, and my test.html file which invokes the QUnit/Pavlov test runner.
My issue is that using the included JSTestDriver example, my RequireJS tests are not getting picked up.
Any help would be greatly appreciated!
I'm able to confirm that an exception is thrown with the throwsException extension. When I provide the string value of the expected error message, it fails to work. The code appears to be comparing objects with each other rather than the string value of the e.message.
I propose to support both the string value of messages and the expected error objects to be thrown.
I know the 'cli for qunit' issue is quite muddled already, but a 'blessed' solution would be nice, especially incorporating pavlov.
Good morning!
...and thanks for this wonderful API - it is incredible intuitive. I'm using it to automate the browser interface tests by attaching an invisible iframe to the document body. Certainly better than iMacros, and I dare say Selenium as well as it is fully cross platform and plugin independent. But that's irrelevant, more to the issue
given([[1],[2]]).it("async test", async(function(a) {
assert(a===1 || a===2).isTrue(); // will fail
resume();
}));
Now if I'm not wrong, and please let me know if I am, this one-line fix should take care of this bugger, it seems to work too:
async: function(fn) {
var implementation = function(){
adapter.pause();
fn.apply(this, arguments); // changed from fn();
};
implementation.async = true;
return implementation;
},
The required files should be qunit.js and qunit.css - there's no default html file to include from QUnit.
Just tried an
assert(function_that_throws_an_error()()).isUndefined();
and it passes, since the error is absorbed.
The title says it all. Can't use the link from the main README.md.
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.