Closed btakita closed 5 years ago
if you set .input
or -input
to "html"
, browser-run run accepts a html file and that can point to any javascript file you want. does that work for you?
It would be useful for me as well. I wanted to run tape tests using browser-run. But I need some custom html to run it. -input html
does not work because the server does not serve my dist/js/*.js
files.
Would something like browser-run --script dist/js/foo.js --script dist/js/bar.js
work for you guys? Maybe help me understand your usecase better as I don't see how that can't be achieved with a custom html file.
Try this:
a.js:
console.log('test')
test.html:
<script src="a.js"></script>
Then browser-run --browser chrome --input html < test.html
. This won't work because the file a.js
won't be accessible from the browser-run server.
one thing you need to keep in mind is that a custom html file will always need to have <script src="/reporter.js"></script>
, i'm adding this to the docs now.
yeah so as i see it we need a static file server at least... I'm thinking
-serve .
to serve a directory at /static/
/static
-serve a.js
to serve a particular fileSince I don't have this use case I'm depending on your input what would work best. My gut says the 2nd option should be the most convenient.
For me I'd prefer to serve the current directory at /
. But then what would happen if there is already a reporter.js
file in that directory?
My use case is running https://github.com/substack/tape but I need to include two files: dependencies.js
and index.js
.
may i ask what's the reason dependencies.js
and index.js
haven't been compiled into the same file? like browserify index.js dependencies.js | browser-run
It''s because dependencies.js
contains all of the external dependencies but I have index.js
and something.js
and yet_another_something.js
.
take this simple example:
// dependencies.js
window.foo = 'bar';
// something.js
console.log(window.foo);
$ browserify dependencies.js something.js | browser-run
bar
I realize that I can bundle it but there is something preventing me from doing that. But maybe I just also realized that I can make that obstacle disappear with small amount of work.
Feel free to close this issue with, possibly, having a comment about multiple js files (or about how they will be injected into html together with fake console.log). On Sep 15, 2015 3:39 AM, "Julian Gruber" notifications@github.com wrote:
take this simple example:
// dependencies.jswindow.foo = 'bar';
// something.jsconsole.log(window.foo);
$ browserify dependencies.js something.js | browser-run bar
— Reply to this email directly or view it on GitHub https://github.com/juliangruber/browser-run/issues/23#issuecomment-140307953 .
awesome! @btakita same for you?
I'd rather allow multiple js files to test external requires & my build script.
I want the code that I test to be the same as, or close to, production code.
On Tue, Sep 15, 2015 at 7:20 PM, Julian Gruber notifications@github.com wrote:
awesome! @btakita https://github.com/btakita same for you?
— Reply to this email directly or view it on GitHub https://github.com/juliangruber/browser-run/issues/23#issuecomment-140578913 .
Brian Takita briantakita.com about.me/brian_takita
In my case I just ended up getting rid of one strange dependency and running:
cat dist/js/dependencies.js dist/js/tests/test.js | browser-run -b chrome
Ok, does that create one concatenated javascript file?
I want to test multiple javascript files, just like how things will be in production.
On Wed, Sep 16, 2015 at 8:57 PM, Tomasz Kołodziejski < notifications@github.com> wrote:
In my case I just ended up getting rid of one strange dependency and running: cat dist/js/dependencies.js dist/js/tests/test.js | browser-run -b chrome
— Reply to this email directly or view it on GitHub https://github.com/juliangruber/browser-run/issues/23#issuecomment-140935661 .
Brian Takita briantakita.com about.me/brian_takita
it would be nice to use a format that concatenates many js files into one but tells browser-run to serve as multiple. something like
pack src/*.js | browser-run -b chrome
i'll try to come up with a poc
ah let's rather keep it simple and have an api like
browser-run -b chrome src/*.js
The concatenation is nice, as long as I can specify multiple individual files:
browser-run -b chrome src/foo.js src/bar.js
-input html
may work. I'll give it a shot & report back. Are there any docs on using -input html
?
I'm attempting to pipe html into a node process, with input: html
by calling the tape-run
module in javascript. The process hangs on GET / :-(
I added logging into browser-run/index.js to debug.
$ echo '<html></html>' | test/tape-run.js
server
server|html
server|html|/
var tapeRun = require('tape-run');
var _ = require("lodash");
function run(opts) {
return tapeRun(_.extend({input: "html"}, opts))
.on('results', console.log)
.pipe(process.stdout);
}
module.exports = run;
if (process.argv[1] == __filename) {
var argv = require("yargs").argv;
run(argv);
}
I agree @btakita , I'm wondering how -input html
works?
does this help? https://github.com/juliangruber/browser-run#custom-html-file
@juliangruber I'm confused with the command. Where do I specify the filename?
@lastmjs maybe this will help more? https://github.com/juliangruber/browser-run/blob/master/index.js#L23
@lastmjs
$ echo myCustom.html | browser-run -input html
That's what the -input
option means, that what you feed into browser-run
is html instead of javascript. Just make sure your html has <script src="/reporter.js"></script>
above all other script tags.
Okay, got it. Thank you.
I'm attempting to pipe html into a node process, with input: html by calling the tape-run module in javascript. The process hangs on GET / :-(
your html is missing the <script src="/reporter.js"></script>
Hey guys, I'm also trying to pipe a html file, however I keep getting a SyntaxError: Unexpected token < error. I know for sure the html is valid. Here is the code:
var stream = fs.createReadStream(__dirname + '/test.html');
stream
.pipe(run([{'browser': 'chrome'}, {'input':'html'}]))
.pipe(tapSpec())
.pipe(process.stdout);
Any ideas why I'm getting this error ? thanks.
try run({browser: 'chrome', input:'html'}))
instead
It works! thanks dude.
Sounds resolved
I'm testing a set of interdependent libraries using browserify. I'd like to load multiple
<script>
tags into<head>
.Right now,
static/index.html
is loaded. I'd like the ability to use a custom html file and/or have a custom handler forGET /
.