Query on Import errors while running automated test case using Jest

Hi All,
We are trying to repackage ef-datetime-picker component using StencilJS. Integration worked well, we are able to use the component. However we are having trouble in executing automated testcase using Jest.
Jest Version : 29
babel version : 7
StencilJs version: 4
Added below code in stencil.config file to parse the component as we were getting import errors.
transformIgnorePatterns: [
"<rootDir>/node_modules/(?!(@refinitiv|lit|@lit|@stencil|ionicons)/)",
],
without the above transformIgnorePatterns below is the exact error.
SyntaxError: Cannot use import statement outside a module
> 1❘ import "@refinitiv-ui/elements/number-field/themes/ds/light";
Λ
2 | import "@refinitiv-ui/elements/icon/themes/ds/light";
3 | import "@refinitiv-ui/elements/tooltip/themes/ds/light";
4
dispatchEvent(
ΑΛΛΛΛΛ
at
with transformIgnorePatterns we are receiving following error.
custom-datetime-picker › renders
App did not load in allowed time. Please ensure the content loads a stencil application.
5 | it("renders", async () => {
6 | const page = await newE2EPage();
> 7 | await page.setContent("<custom-datetime-picker></custom-datetime-picker>");
| ^
8 | const element = await page.find("custom-datetime-picker");
9 | expect(element).toHaveClass("hydrated");
Please suggest how to resolve these errors.
Answers
-
Hello @SubhashK
The team suggest you check this Testing with Jest guideline and see if the issue still occurs.
0 -
Hi @wasin.w ,
We added following config section to package.json, still the test cases are failing. We are getting a warning as shown below. Looks like moduleNameMapper is not taking effect and code is unable to import any module which is nested inside /lib/.
Config Added:
"jest": {
"transformIgnorePatterns": ["node_modules/(?!@refinitiv-ui)/"],
"moduleNameMapper": { "@refinitiv-ui/((?!.*-theme).*?)/(.*)": "<rootDir>/node_modules/@refinitiv-ui/$1/lib/$2" }
}
Warning Received:
[ WARN ] Bundling Warning UNRESOLVED_IMPORT
'@refinitiv-ui/elements/overlay/themes/halo/light' is imported by
src\components\custom-date-picker\custom-date-picker-style.ts, but could not be resolved – treating it as an
external dependency0 -
Also, is it possible to provide the pre-compiled version of @refinitiv-ui node module
"@refinitiv-ui/elements": "^7.10.9",
"@refinitiv-ui/halo-theme": "^7.3.5",
0 -
Hello @SubhashK
The issue needs to be investigated in detail by the Element Framework team. I strongly suggest you contact the team directly. You can contact the team by go to the https://ui.refinitiv.com/ website and select Support —> Contact Us menu.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 249 ETA
- 554 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 643 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 192 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛