bankai icon indicating copy to clipboard operation
bankai copied to clipboard

Tests

Open YerkoPalma opened this issue 8 years ago • 6 comments

This issue is supposed to be a tracker for tests. I think that tests deserve their own folder instead of a single file. Also, I would like to know which issues might be related/resolved with tests, IMO these are:

  • #115
  • #198
  • #205
  • #208

Anyway, if it's fine to use a tests folder, I could start a test branch :) The issue list is just to check. :v:

YerkoPalma avatar Jul 03 '17 13:07 YerkoPalma

Sounds great! :tada:

yoshuawuyts avatar Jul 03 '17 19:07 yoshuawuyts

I've tried to make some first test like this

var tape = require('tape')
var bankai = require('..')
var fs = require('fs')
var path = require('path')

tape('should render example', function (t) {
  t.plan(1)

  var assets = bankai(path.resolve(__dirname, '../example.js'))
  var ws = fs.createWriteStream('bundle.js')
  var jsStream = assets.js()
  jsStream.on('end', function () {
    t.equal(document.querySelector('h1').textContent, 'hello planet')
  })
  jsStream.pipe(ws)
})

I though that would be easy to run with tape-run, but it isn't :( I get the following error

Error: Cannot find module 'fsevents' from '/home/ubuntu/workspace/node_modules/watchify/node_modules/chokidar/lib'
    at /home/ubuntu/workspace/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:46:17
    at process (/home/ubuntu/workspace/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:173:43)
    at ondir (/home/ubuntu/workspace/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:188:17)
    at load (/home/ubuntu/workspace/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/home/ubuntu/workspace/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
    at /home/ubuntu/workspace/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:152:21)
internal/streams/legacy.js:59
      throw er; // Unhandled stream error in pipe.
      ^

Error: javascript required
    at Stream.<anonymous> (/home/ubuntu/workspace/node_modules/tape-run/node_modules/browser-run/index.js:35:34)
    at _end (/home/ubuntu/workspace/node_modules/tape-run/node_modules/through/index.js:65:9)
    at Stream.stream.end (/home/ubuntu/workspace/node_modules/tape-run/node_modules/through/index.js:74:5)
    at Stream.method [as end] (/home/ubuntu/workspace/node_modules/tape-run/node_modules/browser-run/node_modules/duplexer/index.js:47:39)
    at Stream.<anonymous> (/home/ubuntu/workspace/node_modules/tape-run/node_modules/throughout/index.js:7:25)
    at _end (/home/ubuntu/workspace/node_modules/tape-run/node_modules/through/index.js:65:9)
    at Stream.stream.end (/home/ubuntu/workspace/node_modules/tape-run/node_modules/through/index.js:74:5)
    at Stream.onend (internal/streams/legacy.js:44:10)
    at emitNone (events.js:110:20)
    at Stream.emit (events.js:207:7)

Do you have any idea why is this happening? Should I open an issue in tape-run repo or try some different approach on tests?

@yoshuawuyts

YerkoPalma avatar Jul 06 '17 13:07 YerkoPalma

Why are you using tape-run? That's meant for browser testing, but it looks like what you're testing could be done in pure node, no?

timwis avatar Jul 06 '17 15:07 timwis

Oh yeah, what tim said. I believe fsevents is a C++ module which is the origin of that error (e.g. browserify won't have a good time bundling that haha)

On Thu, Jul 6, 2017 at 5:33 PM Tim Wisniewski [email protected] wrote:

Why are you using tape-run? That's meant for browser testing, but it looks like what you're testing could be done in pure node, no?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/choojs/bankai/issues/211#issuecomment-313432474, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWleptATL8nO_EViozRDEWrQ27hvSfBks5sLP5dgaJpZM4OMRi6 .

yoshuawuyts avatar Jul 06 '17 16:07 yoshuawuyts

@timwis just because bankai creates code meant to run in the browser. I could directly check the content of each stream but that's browserify generated code so I though it could be easy with tape-run haha if you have a better idea I would love to hear it :)

@yoshuawuyts more than that, I think the fsevents is an OSX exclusive library, that's why it's usually an OptionalDependency, and I'm working on a linux machine...

YerkoPalma avatar Jul 06 '17 16:07 YerkoPalma

Someone should rewrite watchify using https://github.com/mafintosh/recursive-watch haha; think it'd be way better / way faster to install too (:

On Thu, Jul 6, 2017 at 6:16 PM Yerko Palma [email protected] wrote:

@timwis https://github.com/timwis just because bankai creates code meant to run in the browser. I could directly check the content of each stream but that's browserify generated code so I though it could be easy with tape-run haha if you have a better idea I would love to hear it :)

@yoshuawuyts https://github.com/yoshuawuyts more than that, I think the fsevents is an OSX exclusive library, that's why it's usually an OptionalDependency, and I'm working on a linux machine...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/choojs/bankai/issues/211#issuecomment-313444878, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWlekfbUQFALDab0WDiesb5oXizwijcks5sLQhSgaJpZM4OMRi6 .

yoshuawuyts avatar Jul 07 '17 10:07 yoshuawuyts