Is there a jest config that will fail tests on console.warn?

You can use this simple override : let error = console.error console.error = function (message) { error.apply(console, arguments) // keep default behaviour throw (message instanceof Error ? message : new Error(message)) } You can make it available across all tests using Jest setupFiles. In package.json : “jest”: { “setupFiles”: [ “./tests/jest.overrides.js” ] } Then put … Read more

Jest has detected the following 1 open handle potentially keeping Jest from exiting: TCPSERVERWRAP

I still haven’t found a perfect solution, but for the moment I went for this workaround : jest –config ./test/jest-e2e.json –forceExit The –forceExit option kill the openHandles somehow and unlock everything. Yet, I’m still looking for the “proper way” of handling that issue.

Intl.NumberFormat space character does not match

’11 111.11′.split(”).map(x => console.log((x.charCodeAt(0)))) Yields “32” for the space character which is a normal space. new Intl.NumberFormat(‘fr-CA’).format(11111.11).split(”).map(x => console.log((x.charCodeAt(0)))) Yields “160” for the space character, which is a non-breaking space. To make these tests pass, you need to add the non-breaking space UTF-16 (\xa0) character code into the assertion. expect(formatCurrency(24555.55, ‘fr_CA’, true)).toBe(’24\xa0555,55 $’);

Testing an error thrown by a React component using testing-library and jest

As you already mentioned there is expect().toThrow() 🙂 So in your case: test(“should throw error when not wrapped inside `UserProvider`”, () => { expect(() => render(<TestComponent />)) .toThrow(“Cannot use `useUser` outside of `UserProvider`”); }); Regarding the console.error: Currently there is by design no way to turn off the default error logs. If you want to … Read more

ReferenceError: React is not defined in jest tests

@babel/preset already has support for what you need. According to the react 17 documentation I only had to set the runtime to automatic in my babel.config.json. { “presets”: [ [“@babel/preset-react”, { “runtime”: “automatic” }] ] } If you are using @babel/plugin-transform-react-jsx the config should be { “plugins”: [ [“@babel/plugin-transform-react-jsx”, { “runtime”: “automatic” }] ] } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)