-
Notifications
You must be signed in to change notification settings - Fork 60
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
SyntaxError: Unexpected token export
when importing lux model in jest test
#695
Comments
SyntaxError: Unexpected token export
when importing lux model in jest test
The reason why this is occurring is because Lux is not prebuilt when it is published (by design). This is because the core Lux API is bundled with applications via the Lux CLI. A quick hack to get around this bug would be to run Example: import { UsersController } from '../../dist/bundle';
test('it has a name', async () => {
expect(UsersController).toHaveProperty('name', 'UsersController');
}); For a long term solution, we may have to wait until #681 lands and a public testing api is exposed. That PR contains features like the ability to call your application as a single function which prevents you from having to actually spin up a Lux server for each test. |
Thanks for the advice @zacharygolba - I'll give this a go in the morning but this sounds promising 👍 Being able to call the application from a single function would be super rad as that will, beyond just being the proper way to do things, allow jest to calculate proper coverage but I have worked out a hack to serve the application in a separate process allowing calling the api from a test. That hack does require that I use |
@zacharygolba I've tried this out and it seems to be working. I am at least getting past this error now anyways! Now, I am now getting some new errors but I don't believe they are related to lux itself in any way... I think these are issues with 3rd party libraries that might not be playing nicely with being bundled or something. Thanks again for the advice! |
so I've been tinkering around with this today, back in my isolated test app, and now I've run into a tangential issue. (I can start a new issue if you prefer but this kind of seems like an extension of this one so I figured I'd just tack it on here...) Anyways, I've made some updates to my test app for this and am now getting this error:
For me this has typically always been an issue with how I've setup relationships but this test app only has a user model and no relationships. I've also tested that I can create a user outside of the test and that works fine (testing w/ might you have any ideas for me here? |
I am having issues getting tests run run in jest that import a lux module but I can import other node modules. I setup a barebones lux application that shows this error:
https://github.com/jamemackson/lux-test-error-importing-model
On master I'm getting errors on import and export:
and on the
babel-preset-env
branch only export is throwing errors (diff):the offending test is the same in both branches:
Darwin WEDMAC201505.domain 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
The text was updated successfully, but these errors were encountered: