Skip to content

Karma + Babel won't run tests #1286

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

Closed
N3ll opened this issue Dec 1, 2015 · 14 comments
Closed

Karma + Babel won't run tests #1286

N3ll opened this issue Dec 1, 2015 · 14 comments

Comments

@N3ll
Copy link
Contributor

N3ll commented Dec 1, 2015

From @stevetayloruk on November 30, 2015 12:7

When using Babel/ES6 and unit tests (mocha or jasmine - tried both) I'm getting an error when the tests run. The error i think is down to the the babel after-prepare as disabling this gets rid of the error but then the app doesn't run. I'm using "tns test ios --emulator" command.

The error I'm getting is:

30 11 2015 11:46:42.230:INFO [karma]: Karma v0.13.15 server started at http://localhost:9876/
30 11 2015 11:46:42.236:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Successfully prepared plugin nativescript-unit-test-runner for ios.
Project successfully prepared
Executing after-prepare hook from /Users/stevetaylor/Projects/raise/raise-app/raise/hooks/after-prepare/nativescript-dev-babel.js
Cannot read property 'appDestinationDirectoryPath' of undefined
# test ios

and the tests do not run.

Any ideas?

Thanks

Steve

Copied from original issue: NativeScript/NativeScript#1182

@tailsu
Copy link
Contributor

tailsu commented Dec 1, 2015

It's was bug in the Babel hook. Try updating the nativescript-dev-babel to 0.1.4 and see if the problem goes away.

@stevetayloruk
Copy link

Yes, that has fixed the error.

Still can't get them to run though. App is saying No reachable hosts now. Must be a config issue i guess.

@tailsu
Copy link
Contributor

tailsu commented Dec 8, 2015

The app runs in the simulator and says "No reachable hosts"? I can't see how this could be possible, as the simulator shares the network interfaces of the host. Can you paste in the contents of node_modules/nativescript-unit-test-runner/config.js, please?

@stevetayloruk
Copy link

module.exports = {"port":9876,"ips":["192.168.1.68"],"options":{"debugTransport":false,"debugBrk":false}}

@tjvantoll
Copy link
Contributor

I’m hitting the same issue. I have the same config.js, and tns test ios --emulator gives me a screen that says “no reachable hosts”.

@jasssonpet
Copy link
Contributor

Hello, @tjvantoll,

I know this is a long shot, but can you open your <APP>/platforms/ios/build/emulator/<APP>.app/Info.plist and check if there is a key for NSAppTransportSecurity. If it's missing, that might be blocking the requests to the server.

If this is the case, you should run tns emulate ios first (in order the test plugin to be prepared), and then your second tns test ios command should succeed.

I've had a similar problem, so I hope this helps 😄

@tjvantoll
Copy link
Contributor

Hey @jasssonpet,

The {N} CLI seems to automatically add NSAppTransportSecurity to my Info.plist every time I exectute tns test ios. I’m assuming that flag needs to be set for the tests to run successfully?

@tailsu
Copy link
Contributor

tailsu commented Jan 4, 2016

Yes, it does, because the unit test client connects to the Karma server over plain HTTP. Is what you're saying that the flag is set, but the emulator still shows "no reachable hosts"? Have you tried deleting the platforms/ios/ folder and rebuilding?

@tailsu
Copy link
Contributor

tailsu commented Jan 4, 2016

@tjvantoll
Copy link
Contributor

Is what you're saying that the flag is set, but the emulator still shows "no reachable hosts"?

Correct. I have the code below in my Info.plist, and I still see “no reachable hosts” when I run tns test ios.

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

Have you tried deleting the platforms/ios/ folder and rebuilding?

I just tried that and I have the same problem. Here’s exactly what I’m running:

git clone https://github.com/NativeScript/sample-Groceries.git
cd sample-Groceries
tns init
tns emulate ios
tns test ios --emulator

@ligaz
Copy link

ligaz commented Jan 7, 2016

It looks like the issue is caused by a newly release version of the socket.io client library referenced by karma. If you manually revert to the old version of the library (change the contents of node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/socket.io.js to https://raw.githubusercontent.com/socketio/socket.io-client/1.3.7/socket.io.js) the tests are executed. Unfortunately Karma is referencing socket.io with ^ which causes this incorrect behavior.

We will continue the investigation on our side.

@ligaz
Copy link

ligaz commented Jan 7, 2016

Pull Request issued against socket.io that handles the issue: socketio/socket.io-client#932

@ligaz
Copy link

ligaz commented Jan 11, 2016

Another one: socketio/engine.io-client#453

@ligaz
Copy link

ligaz commented Jan 27, 2016

🎉 Good news everyone. Socket.io has a new version that has the fix included. Just nuke your node_modules and npm install again.

@ligaz ligaz closed this as completed Jan 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants