bebraw / bunit.js Goto Github PK
View Code? Open in Web Editor NEWSimple testing lib for JS (MIT)
License: MIT License
Simple testing lib for JS (MIT)
License: MIT License
The call to require.ready
seems to be deprecated in the latest versions of RequireJS. The fix is to use domReady
per https://requirejs.org/docs/api.html#pageload.
Would it be possible to add a more complex async test... perhaps one that actually spoofs the server and does a full ajax request? Just for test completeness sake:
define(function(require) {
var bunit = require("external/bunit/bunit");
var assert = require("external/bunit/assert");
var $ = require("jquery");
bunit("Request manager", {
tearDown: function() {
$(".btn").click();
},
asyncTest: function(o, done) {
var server = sinon.sandbox.useFakeServer();
server.respondWith("GET", "/test/1", [
200, { "Content-Type": "application/json" },
'{"response": "some_response"}'
]);
// call stop(); now if you want, since we named our test using async prefix,
// that won't be needed
$.ajax({
type: "GET",
url: "/test/1",
success: function(data) {
assert(data.response).equals("some_response");
done();
}
});
server.respond();
}
});
});
I use sinon for spoofing server responses in some of my tests. I recently converted to bunit and all is well. It does however seem that sometimes, it doesn't wait for my asynchronous tests to complete. Is there a way to make a specific test wait until all of the asserts are done?
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.