Giter VIP home page Giter VIP logo

Comments (16)

TehShrike avatar TehShrike commented on June 22, 2024

You have to run your test html file with browserstack-runner - it injects the JavaScript files that setup up that global.

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

that's the fascinating thing. i did a Live session and even the console in the virtual machines browser said BrowserStack was undefined.

from browserstack-tape-reporter.

TehShrike avatar TehShrike commented on June 22, 2024

Can you give any more details about your setup? Everything seems to be working fine for me. See abstract-state-router for an example of a working browserstack test, and this post for instructions on setting it up.

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

sure, so I did indeed read your post, and it was great, but I happen to also be using rewire and the support for browserify is icky in comparison to webpack, so I switched over to webpack because there's a well maintained rewire loader. here's the setup as a gist:

https://gist.github.com/moimikey/2a06d21f2e114f0b6fc7

lemme know if there's another file that you'd like to see that may pertain to the ones included in the gist.

from browserstack-tape-reporter.

TehShrike avatar TehShrike commented on June 22, 2024

It looks like by default browserstack-runner injects its <script> tag right before the closing </body> tag. Maybe you should move your <script> to be after the body element (which I think is what you should be using if you're using tape without using document-ready anyway).

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

@TehShrike gonna give this a try. that actually makes a lot of sense... will report back :)

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

hm. still no dice sadly.. (screenshot is an interactive session from Automate)
screen shot 2015-11-07 at 1 24 59 pm

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

the test:

var test    = require('tape')
var rewire  = require('rewire')
var locale2 = rewire('./')

test('locale2 returns a locale', function (t) {
  t.plan(2)
  locale2.__with__({
    clientInformation: {
      language: 'en-AA'
    }
  })(function() {
    t.equal(typeof locale2(), 'string')
    t.equal(locale2(), 'en-AA')
    t.end()
  })
})

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

also, i don't think it should display undefined on the page?
screen shot 2015-11-07 at 1 29 36 pm

from browserstack-tape-reporter.

TehShrike avatar TehShrike commented on June 22, 2024

What is the exact html being served up by browserstack-runner?

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

@TehShrike i dunno HOW but i fixed it ;O... i now have it successfully working with webpack, browserstack and tape. i smell a blog entry...

I'm genuinely not sure what changed... it may of been my webpack config? i changed the ordering of the tape reporter plugin. that may of been it:

var RewirePlugin = require('rewire-webpack')

module.exports = {
  devtool: 'eval',
  entry: [
    './node_modules/browserstack-tape-reporter/index.js',
    './test-bs.js'
  ],
  output: {
    path: __dirname,
    filename: 'test-bs.bundle.js'
  },
  plugins: [
    new RewirePlugin()
  ],
  node: {
    fs: 'empty'
  }
}

the test. i originally was including index.js which was exports.locale2 = require('./src').locale2:

"use strict"

var test     = require('tape')
var rewire   = require('rewire')
var lib      = rewire('./src')
var locale2  = lib.locale2

test('locale2 returns a string when called', function (t) {
  t.plan(1)
  t.equal(typeof locale2(), 'string')
  t.end()
})

test('locale2 returns an lcid string', function (t) {
  t.plan(1)
  lib.__with__({
    global: {
      clientInformation: {
        language: 'en-AA'
      }
    }
  })(function() {
    t.equal(locale2(), 'en-AA')
    t.end()
  })
})

and i doubt this matters, but I ran the browserstack-runner with --verbose this time, which gave me the test output. was it something as stupid as the --verbose flag maybe??

2:33 PM mshertzberg@forge locale2 master ? npm run test-bs                                                              0.12.7

> locale2@1.0.0 test-bs /Users/mshertzberg/Git/locale2
> ./test-bs.sh

Hash: b4b065c3716e1ebf2974
Version: webpack 1.11.0
Time: 795ms
            Asset    Size  Chunks             Chunk Names
test-bs.bundle.js  221 kB       0  [emitted]  main
   [0] multi main 40 bytes {0} [built]
  [57] ./test-bs.js 2.13 kB {0} [built]
  [59] ./src/index.js (rewired) 4.79 kB {0} [not cacheable] [built]
    + 58 hidden modules
Using config: /Users/mshertzberg/Git/locale2/browserstack.json
Launching server on port: 8888
Downloading BrowserStack Local to "/Users/mshertzberg/Git/locale2/node_modules/browserstack-runner/lib/BrowserStackLocal"
[Sat Nov 07 2015 14:33:58 GMT-0500 (EST)] Launching tunnel
[Sat Nov 07 2015 14:34:00 GMT-0500 (EST)] Tunnel launched
Launching 1 worker(s) for 1 run(s).
[OS X Lion, Firefox latest] Finding version.
[OS X Lion, Firefox latest] Version is 42.0.
[OS X Lion, Firefox 42.0] Launching
[OS X Lion, Firefox 42.0] Launched
[OS X Lion, Firefox 42.0] Awaiting ack
[OS X Lion, Firefox 42.0] Received ack
[OS X Lion, Firefox 42.0] # locale2 returns an lcid string
[OS X Lion, Firefox 42.0] # locale2 returns a string when called
[OS X Lion, Firefox 42.0] TAP version 13
[OS X Lion, Firefox 42.0] ok 1 should be equal
[OS X Lion, Firefox 42.0] ok 2 should be equal
[OS X Lion, Firefox 42.0] Passed: 2 tests, 2 passed, 0 failed; ran for 21ms
[OS X Lion, Firefox 42.0]
[OS X Lion, Firefox 42.0] # tests 2
[OS X Lion, Firefox 42.0]
[OS X Lion, Firefox 42.0] 1..2
[OS X Lion, Firefox 42.0] # pass  2
[OS X Lion, Firefox 42.0]
[OS X Lion, Firefox 42.0] # ok
[OS X Lion, Firefox 42.0] Terminated
All tests done, failures: 0.
Exiting

best,
M

from browserstack-tape-reporter.

TehShrike avatar TehShrike commented on June 22, 2024

Wacky. I'll add a note to the readme.

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

love that you made this. it's great ❤️. closing

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

@TehShrike i feel like such an idiot :(. i now really know what the problem was... it was my browserstack.json...

  "test_path": "./test-bs.html",

i set the test_path with ./... after removing that, it actually then worked. the problem was that the runner was never able to get to the test-bs.html page in the first place to run the test, therefore what was showing was undefined because it had no actual page to go to because the path was wrong.

sowwee

from browserstack-tape-reporter.

TehShrike avatar TehShrike commented on June 22, 2024

ah, whew! Better than arcane webpack weirdness. :-)

from browserstack-tape-reporter.

moimikey avatar moimikey commented on June 22, 2024

yeah really. that was skurry. thanks for chiming in!

from browserstack-tape-reporter.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.