Import {Socket} from "phoenix" causes PhantomJS error

I just updated from Phoenix 1.4 to 1.6, and per the update instructions about adding LiveView, I added

import {Socket} from "phoenix"

to my app.js file (along with all the other necessary code, but this line alone is sufficient to break PhantomJS). I use Karma and PhantomJS for my js tests, and adding this line causes this error whenever I try to run my test suite:

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
{
“message”: “An error was thrown in afterAll\nSyntaxError: Unexpected token ‘>’”,
“str”: “An error was thrown in afterAll\nSyntaxError: Unexpected token ‘>’”
}

Dev site works fine and console doesn’t have a peep, so I’m thinking it must be PhantomJS.

I also just noticed that I was already importing phoenix Socket in another part of my code. It was vestigial and never being used, but the import was happening during testing, and it didn’t break, so maybe it has something to do with changes in either 1.5 or 1.6 and PhantomJS.

Anyone experience something similar or can provide some guidance?

A quick google seems to suggest phantomJS never managed to release ES6 support. I’d probably suggest moving away from phantomjs given its last release was in 2016, which in js terms is aeons ago.

1 Like