3rd-Eden / useragent

Useragent parser for Node.js, ported from browserscope.org
MIT License
899 stars 135 forks source link

Jest hangs while importing useragent lib #131

Open himalayagupta opened 5 years ago

himalayagupta commented 5 years ago

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 commented 3 years ago

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 commented 3 years ago

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...