Comments (16)
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.
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.
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.
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.
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.
@TehShrike gonna give this a try. that actually makes a lot of sense... will report back :)
from browserstack-tape-reporter.
hm. still no dice sadly.. (screenshot is an interactive session from Automate)
from browserstack-tape-reporter.
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.
also, i don't think it should display undefined
on the page?
from browserstack-tape-reporter.
What is the exact html being served up by browserstack-runner?
from browserstack-tape-reporter.
@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.
Wacky. I'll add a note to the readme.
from browserstack-tape-reporter.
love that you made this. it's great ❤️. closing
from browserstack-tape-reporter.
@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.
ah, whew! Better than arcane webpack weirdness. :-)
from browserstack-tape-reporter.
yeah really. that was skurry. thanks for chiming in!
from browserstack-tape-reporter.
Related Issues (2)
- Test timing out HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from browserstack-tape-reporter.