Reputation: 6998
I'm trying to load my dependencies into a JSDom environment then execute a basic test.
When I run this file with mocha, it tells me that the maximum timeout of 2000 milliseconds has been exceeded.
// Node Dependencies
import { readFileSync } from 'fs';
// NPM Dependencies
import { expect } from 'expect';
import { jsdom } from 'jsdom';
// JSDom Configuration
const html = '<!doctype html><html><body></body></html>';
const dep1 = readFileSync("./dep1.js", "utf-8");
const dep2 = readFileSync("./dep2.js", "utf-8");
const scripts = [ dep1, dep2 ];
describe('App Actions', function(){
it('sample test', function(done){
// Use JSDom to mock a browser environment,
// loading the necessary scripts, then executing the callback.
jsdom(html, scripts, callback);
function callback(err, window){
expect(false).toEqual(true);
done();
}
});
});
Any ideas?
I think it has something do with jsdom, since if I change the callback to look like this:
function callback(err, window){
console.log(window);
expect(false).toEqual(true);
done();
}
It never runs the console.log
.
Upvotes: 0
Views: 1151
Reputation: 4398
You are importing jsdom.jsdom
but using the syntax for jsdom.env
(which does expect a callback as a third parameter). Change this line:
import { jsdom } from 'jsdom';
To:
import { env } from 'jsdom';
Upvotes: 1