jamesshore / quixote

CSS unit and integration testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stylesheets in array causing error

ozee opened this issue · comments

I am getting an error, Error: Uncaught Error: Not a constructor (node_modules/quixote/dist/quixote.js:1003), when passing stylesheets through an array in the options to createFrame. Here is an example of the code I am using to accomplish this based on the api docs.

const quixote = require('quixote/dist/quixote.js');

describe('Div test', () => {
    let frame;
    let div;

    before(done => {
        const options = {
            stylesheet: [
                '/base/stylesheet-1.css',
                '/base/stylesheet-2.css'
            ],
            width: 480
        };

        frame = quixote.createFrame(options, done);
    });

    beforeEach(() => {
        frame.reset();
        frame.add(`<div id="hello-world">Hello World</div>`);
        div = frame.get('#hello-world');
    });

    after(() => {
        frame.remove();
    });

    /* tests */
});

Thanks, I'm looking into it.

I've tried your example code and it works fine for me. It looks like you're using something Babel. Are you sure it's working properly with the 'require' statement? Does the code work if you take the options out?

It that's not the problem, I'll need more information: the full stack trace, and also the code that the stack trace points to (assuming you're using Babel or something similar). Line 1003 in my codebase is just a comment.

Yes, I am using Babel, pretty standard setup targeting es2015. It does work if I remove the array and only import one stylesheet. I will post a full stacktrace tomorrow since I don't have it in front of me right now.

I really like the library and have some odd 200+ tests across a dozen or so files and had a need for multiple stylesheets for a group of tests and just happened to have this happen. Thanks for the quick response!

Odd. I've just double-checked and it does work for me with two stylesheets. However, I didn't bother using Babel--I just translated the code by hand. This is the test I ran... give it a try and see if you see a different result:

// Copyright (c) 2014 Titanium I.T. LLC. All rights reserved. For license, see "README" or "LICENSE" file.
"use strict";

var assert = require("./util/assert.js");
var quixote = require("./quixote.js");

describe('FOUNDATION: Div test', function() {
	var frame;
	var div;

	before(function(done) {
		var options = {
			stylesheet: [
				'/base/src/_q_frame_test.css',
				'/base/src/_q_frame_test2.css',
			],
			width: 480
		};

		frame = quixote.createFrame(options, done);
	});

	beforeEach(function() {
		frame.reset();
		frame.add('<div id="hello-world">Hello World</div>');
		div = frame.get('#hello-world');
	});

	after(function() {
		frame.remove();
	});

	/* tests */

	it("runs tests", function() {
	});
});

If that still doesn't work, it may be an interaction with a specific test.

Another thing to try is this test from Quixote's unit test suite:

https://github.com/jamesshore/quixote/blob/release/src/_q_frame_test.js#L91-L107

As you can see, we're testing this exact scenario, so something strange is going on here.

This is working for me now, for some reason my package installed an older version of Quixote (0.5.0) instead of the current version. Once I realized this, I updated and everything is working to spec. I appreciate the help, now I am scratching my head as to why it installed that version and not the current version.

Thanks, glad you figured it out!