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

Works in everything EXCEPT Electron #135

Closed
beverlycodes opened this issue Mar 13, 2017 · 11 comments
Closed

Works in everything EXCEPT Electron #135

beverlycodes opened this issue Mar 13, 2017 · 11 comments

Comments

@beverlycodes
Copy link

beverlycodes commented Mar 13, 2017

I don't know what I could be getting wrong in my setup, but I can't seem to make this work using Electron.

Running with cat build/index.html | browser-run --input html --static build

Folder structure is

build/
  bundle.js
  index.html

css/
  ... source files ...

html/
  ... source files ...

js/
  ... source files ...

node_modules/
  ... node modules ...

package.json
webpack.config.js

index.html is

<div id="app"></div>
<script type="text/javascript" src="/reporter.js"></script>
<script type="text/javascript" src="/bundle.js"></script>

I've stripped down my bundle so that the only code going into it is some babel runtime code and:

import test from 'tape'

test.onFinish(function(){
  window.close();
});

test('test ok', function (t) {
  t.ok(true)
  t.end()
})

If I use the -b or --port options, everything works as expected. If I leave those options off, Electron tries to run but just outputs SyntaxError: Unexpected token < and immediately exits.

Adding --basedir build causes Electron to create a file called .source.[timestamp].html and the contents of that file are:

<body><script><div id="app"></div>
<script type="text/javascript" src="/reporter.js"></script>
<script type="text/javascript" src="/bundle.js"></script>
</script></body>

However, nothing is output and Electron just hangs until I hit Ctrl-C.

Meanwhile, using a browser (-b or --port), I get exactly the output I expect:

TAP version 13
# okay
ok 1 should be truthy

1..1
# tests 1
# pass  1

# ok
@nstanard
Copy link

nstanard commented Mar 13, 2017

My team had to target a specific version of browser-run after the build started failing where I work. It was kinda annoying but we got through it. Thanks for taking the time and opening this though. I believe it's the same issue.

We added this to our package.json file as a workaround for the error message you are referencing.
"browser-run": "3.4.0",

@nstanard
Copy link

nstanard commented Mar 13, 2017

One of the developers I work with narrowed it down to:

https://github.com/juliangruber/browser-run/blob/master/lib/launch.js#L12

v3.5.0...master#diff-8e402bf78d4c5f8a4fb797709e5bc7a3R12

Worked up until 3.6.0 (first occurrence of break)

@juliangruber
Copy link
Owner

Oh, dang, yeah that only doesn't work in electron currently. Will get a fix out this week!

@juliangruber
Copy link
Owner

(will also add tests for this!)

@juliangruber
Copy link
Owner

can you check if 4.0.2 works for you?

@nstanard
Copy link

To test this I'd need to update my tape-run version from 2.1.4 -> 3.0.0. 🤔

@nstanard
Copy link

@juliangruber Removed browser-run from my package file and instead installed 3.0.0 of tape-run. I still got the same error though.

SyntaxError: Invalid or unexpected token

@beverlycodes
Copy link
Author

It may be working now, but I'm not certain and the issue flipped.

I am able to complete a test run, but a bunch of my tests aren't running. I went to rule out Electron itself as the problem but now --port and -b are doing what the Electron path perviously did. With -b, the browser opens and then just waits for a server response forever. When I connect via port I get the same behavior. If the browser is waiting and I Ctrl-C browser-run, the browser immediately reports that it can't connect to the server, so I know it's trying to connect and run and there's just nothing responding.

@juliangruber
Copy link
Owner

@juliangruber Removed browser-run from my package file and instead installed 3.0.0 of tape-run. I still got the same error though.

SyntaxError: Invalid or unexpected token

you could run this with [email protected] or [email protected]. Also make sure to clean your npm cache before upgrading (npm cache clean) to make sure you get tu=he current versions.

One syntax error bug was fixed yesterday.

@tschant
Copy link

tschant commented Mar 17, 2017

Update (I work with @nstanard): ran with [email protected] and [email protected] (after cache clean) and got SyntaxError: Invalid or unexpected token again, it seems to be hitting adb7c32#diff-8e402bf78d4c5f8a4fb797709e5bc7a3R13
We are using default (empty) options when running tape-run.

@juliangruber
Copy link
Owner

the http:// protocol is back! (in the current version)

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

4 participants