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.

Bug(Tests): Testfile not launching in ESM mode

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Which Transloco package(s) are the source of the bug?

Transloco, Scoped Libs

Is this a regression?

No

Current behavior

I am using this minimum repro repository I’ve made (see in the dedicated area underneath) So it’s using Angular 14, Transloco, Spectator (it’s pretty much all, and it’s the stack i’m using in my real project so I kinda need this stack to work 🙏 )

When I launch the test from the root directory with
node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=projects/ticketing-lib-ui-library/jest.config.mjs --no-cache I get this error : image

After a bit of search, I found that when I change the import of ‘flat’ in the file node_modules@ngneat\transloco\fesm2020\ngneat-transloco.mjs

from this:

import { unflatten as unflatten$1, flatten as flatten$1 } from 'flat';

to this:

import * as flat from 'flat'; const unflatten$1 = flat.unflatten; const flatten$1 = flat.flatten;

I get another error after launching the tests:

image

Expected behavior

I expect the test to pass as it is only a “should init” test.

Please provide a link to a minimal reproduction of the bug

https://github.com/jnain/minimum-transloco-spectator-repro

Transloco Config

Not relevant and can be found in the repo (but not sure it is complete as I removed a lot of my project)

Please provide the environment you discovered this bug in

Transloco: ~4.1.1
Angular: ^14.1.0
Node: v16.16.0
Package Manager: npm 8.11.0
OS: Windows

Browser

Jest test framework

Additional context

No response

I would like to make a pull request for this bug

If you really help me for this I can but as it is touching to your exported types, I’m not sure I can help…

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
jnaincommented, Sep 27, 2022

I seem to have fix this problem in my PR, I would like to have some news about all of this please…

0reactions
angelnikolovcommented, Nov 15, 2022

@jnain Yeah thinking of doing the same. Thanks man! Really helpful!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support ESM when watch mode reruns files #1693 - GitHub
Running qunit -w . On first run it successfully outputs the results of the tests, upon making a change to the test file,...
Read more >
How to use ESM tests with jest? - Stack Overflow
Here are the steps I took to run Jest with a test using ESM. The source files under test were also written using...
Read more >
Configuring Jest
A list of paths to modules that run some code to configure or set up the testing environment. Each setupFile will be run...
Read more >
Testing in parallel with Mocha v8.0.0 - IBM Developer
js. Running tests in parallel mode allows Mocha to take advantage of multi-core CPUs, resulting in significant speedups for large test suites.
Read more >
Mocha - the fun, simple, flexible JavaScript test framework
When a test file is loaded, Mocha executes all of its suites and finds–but does not execute–any hooks and tests therein. Top-level hooks,...
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