Skip to content
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

Jest hangs while importing useragent lib #131

Open
himalayagupta opened this issue Oct 1, 2018 · 2 comments
Open

Jest hangs while importing useragent lib #131

himalayagupta opened this issue Oct 1, 2018 · 2 comments

Comments

@himalayagupta
Copy link

Hi,
i am writing tests in Jest.
testmodule.js
import useragent from 'useragent';
export sample()
{
return useragent.parse(value);
}

test.js
import sample from './testmodule.js'
describe('my reducer', () => {
it('should return the initial state', () => {
expect("hello").toEqual("hello")
})

when i run this test, "jest", the file hangs. If i comment the useragent lib import, then my test runs successfully.

Env:
React- 16.x
Node - 8.x

Can you please help me out here on what could be the issue here? Thanks

@VanceBeckett
Copy link

Same thing, using typescript with target "es6" or any other. Works fine in prod tho... Seems like this lib has some issue with jest/ts-jest. Don't have time to debug -_-

TypeError: Class constructor LRUCache cannot be invoked without 'new' - getting this on useragent import statement on all tests, that rely on useragent.

node 14.12

@VanceBeckett
Copy link

VanceBeckett commented Oct 3, 2020

Okay, I've got it. This will fix the problem, will make a PR:

var LruCache = require('lru-cache')
var LRU = new LruCache(5000)

Just saw that this bug was already fixed in master (7 long months ago), but remains unpublished to npm...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants