question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UI: npm test fails with an error

See original GitHub issue

npm test

fails with an error: ` …BaGet.UI\node_modules\office-ui-fabric-react\lib\Icon.js:1 ({“Object.<anonymous>”:function(module,exports,require,__dirname,__filename,global,jest){export * from ‘./components/Icon/index’; ^^^^^^

SyntaxError: Unexpected token export

1 | import { HtmlRenderer, Parser } from ‘commonmark’;

2 | import { Icon } from ‘office-ui-fabric-react/lib/Icon’; | ^ 3 | import * as React from ‘react’; 4 | import timeago from ‘timeago.js’; 5 | import LicenseInfo from ‘./LicenseInfo’;

at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17) at Object.<anonymous> (src/DisplayPackage.tsx:2:1) `

similar to this https://github.com/facebook/jest/issues/2550

I have updated npms to the latest but it does not resolve the issue.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
loic-sharmacommented, Jun 24, 2020

I’ll keep the patter that Create React Script use.

Sounds good to me

But I’m stuck with mocking the fetch request. I saw that you have a __BAGET_PLACEHOLDER_API_URL__ on the config.tsx. What’s the purpose of this?

Good question! This can be used by two things:

  1. Normally, the BaGet backend serves the BaGet react app, and the react app uses relative URLs. These URLs is broken if you add a prefix to BaGet’s URLs (example: /upload would become /my-prefix/upload). We’re working on a fix to this problem here, it works by replacing that __BAGET_PLACEHOLDER_API_URL__ value as we serve the BaGet react app.
  2. This lets you run the BaGet react app separately from the BaGet backend. Say you run the backend at URL https://my-baget-api, you can create a deployment step where you replace __BAGET_PLACEHOLDER_API_URL__ with https://my-get-api. This is a hidden feature that I should document 😃

I’m asking because I have an issue while runing tests. The test require a full URL to mock, not just /v3/search?....

Hm. Could you use custom environment variables (see this) to override the API URL?

1reaction
sipmanncommented, Jun 15, 2020

awesome, I’ll make a branch and start working on this new features and fill an issue next week to keep track. I’ll fix the tests and code a few ones. React testing isn’t my strongest front-end test unit but I’m sure we can improve what we have here 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm test failing without any error message
The tests are failing with no errors and just with above message. My test script is: "test": "TEST=true tape test/core/*.js test/core/ ...
Read more >
npm test and yarn test fail with no error message #2770
Hello, it seems like this is an issue with Jest which fails when it is called with the --watch argument. Feel free to...
Read more >
Common errors
Random errors. Some strange issues can be resolved by simply running npm cache clean and trying again. If you are having trouble with...
Read more >
Error running the UI on the test app - Daml Forum
Just trying to get the create-daml-app UI running. ... The particular error, ENOENT means that npm has failed to open a file or...
Read more >
Build goes green even though my testsuite fails (Create ...
I'm testing my React application made with Create React App. My test command (npm test) executes react-scripts test.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found