Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for tap(e) tests #5

Open
MoOx opened this issue Feb 24, 2015 · 4 comments
Open

Add support for tap(e) tests #5

MoOx opened this issue Feb 24, 2015 · 4 comments

Comments

@MoOx
Copy link

MoOx commented Feb 24, 2015

That would be cool.
Any idea how we can do that ?
I see that for other frameworks you use a global var, but tape don't have any (commonjs like code via browserify or webpack).
I would really like to use saucie with tape tests.

@johanneswuerbach
Copy link
Owner

How do you determine the result of your tests when using tape? Looking at the console?

@MoOx
Copy link
Author

MoOx commented Feb 24, 2015

Exactly. That's what is already doing testem https://github.com/airportyh/testem/blob/master/views/taprunner.mustache
But I think we need to add something more so saucelab can detect the result.

@MoOx
Copy link
Author

MoOx commented Feb 24, 2015

@AsaAyers
Copy link

I came up with a way to make this work. If you don't have window.mocha, window.QUnit, or window.jasmine defined, then JSTestingReporterSL ends up being undefined, and you can define it yourself before running tests.

function setupSaucieReporter(tape) {
    // Force tape to create the harness now with the default stream
    tape.getHarness()

    // Now create a 2nd stream (1st is created inside getHarness)
    const stream = tape.createStream({ objectMode: true })

    let tests = 0
    let fail = 0
    let pass = 0
    stream.on('data', function (row) {
        if (row.ok != null) {
            tests++
            if (row.ok) {
                pass++
            } else {
                fail++
            }
        }
    })

    return function() {
        return {
            passed: ( fail == 0 ),
            // I don't know what I should add for custom-data
        }
    }
}

// I think this should be run as early as possible.
global.JSTestingReporterSL = setupSaucieReporter(require('tape'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants