Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow other objects to be exported in test files. #284

Closed
wants to merge 2 commits into from

2 participants

@NemoPersona

More flexible test files, for my test suite I wanted to export other objects from the same test file (module) and vows did not like that idea as it tries to run every object that is exported by the module as a test.

There are several other reasons why one would want to export from within the same file, ofc the main one is to keep the project structure clean. I could have split the files but going from 1 to 2/3 files is just cumbersome and a small change inside vows was easier to deal with.

Example test file:

var complexVar = {};
var complexTest = function () {};

vows.describe('The Good Things').addBatch({
    'A strawberry': {
        topic: new(Strawberry),
        'is red': function (strawberry) {
            var color = complextTest(strawberry);
            assert.equal (color, '#ff0000');
        }
    }
}).export(module);

module.exports.var = complexVar;
module.exports.test = complexTest;

If I missed something and there is a cleaner way to do this already, feel free to point it out to me.

@indexzero
Owner

:+1: in principle, but we need to investigate this more and have tests.

@indexzero indexzero added the v0.9.0 label
@indexzero indexzero referenced this pull request from a commit
@indexzero indexzero [api] Allow for multiple exports in required test files. Fixes #284 b…
…y manual merge of changes from @NemoPersona.
a5a124d
@indexzero
Owner

Cherry-picking commits from a repo that has been deleted into a feature branch is basically impossible @NemoPersona, sorry I couldn't grab your commits explicltly, but I attributed you in the commit message in a5a124d

@indexzero indexzero closed this
@indexzero indexzero referenced this pull request
Merged

v0.9.0-rc1 #328

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +2 −1  bin/vows
  2. +1 −0  lib/vows/suite.js
View
3  bin/vows
@@ -467,7 +467,8 @@ function runSuites(suites, callback) {
(function run(suites, callback) {
var suite = suites.shift();
- if (suite) {
+ if( (options.isolate && suite) ||
+ (suite && suite.type && suite.type === 'vows')) {
msg('runner', "running", suite.subject + ' ', options.watch ? false : true);
suite.run(options, function (result) {
Object.keys(result).forEach(function (k) {
View
1  lib/vows/suite.js
@@ -5,6 +5,7 @@ var vows = require('../vows');
var Context = require('../vows/context').Context;
this.Suite = function (subject) {
+ this.type = 'vows',
this.subject = subject;
this.matcher = /.*/;
this.reporter = require('./reporters/dot-matrix');
Something went wrong with that request. Please try again.