jamesshore / quixote

CSS unit and integration testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow for passing in styles as a string instead of a url

SamGraber opened this issue · comments

I think it would be helpful if you could pass in styles as a string instead of giving quixote a stylesheet url. This would give users greater flexibility for how they pull in stylesheets, as they could use require() or something similar to import the styles and then pass them into quixote directly.

We are considering quixote for style testing in our project. Currently, our project uses less, but we'll shortly be migrating to sass instead. I'm thinking we could use a bundler like webpack to load our less/scss files and process them into css before passing the styles into quixote. This would be easier to do if we could pass them in directly instead of letting quixote load them.

Makes sense! If you'd like this to happen sooner, send me a pull request. The file that controls this is src/q_frame.js (and src/_q_frame_test.js). See CONTRIBUTING.md in the top level for instructions on building the code.

I'm imagining a new css parameter in the QFrame options object, like this:

	it("creates iframe using raw CSS and source URL simultaneously", function(done) {
			var options = {
				src: "/base/src/_q_frame_test.html",
				css: ".style-me { font-size: 42px; }"
			};

			QFrame.create(window.document.body, options, function(err, frame) {
				var styleMe = frame.get(".style-me");
				assert.equal(styleMe.getRawStyle("font-size"), "42px");
				done();
			});
		});
	});

As of the current version, the place to add the tests is line 121 in _q_frame_test.js. The code to modify in q_frame.js is onFrameLoad(), probably after the call to loadStylesheets(). (After line 64 of the current version.)

Blocked on 0.13 release.

Integrated and will be included in v0.13 release.

Released in v0.13.