Categories
Mastering Development

Property ‘toBeInTheDocument’ does not exist on type ‘Matchers

Trying to setup testing for a components library. I’ve tried many example and all similar threads on this with no luck. My setupTests.ts file is correctly being loaded (proven with a console.log), and the library seems to be available as if I add import { toBeInTheDocument } from ‘@testing-library/jest-dom/matchers’ and log toBeInTheDocument it is present. […]

Categories
Development

Importing local files in `jest.config.js` file

In my jest.config.js file, I need to populate globals property. For populating the globals property I need to require local modules, as shown below: const path = require(‘path’) const server = require(‘./server/cfg’) module.exports = { rootDir: path.resolve(__dirname), moduleFileExtensions: [ ‘js’, ‘json’, ‘vue’, ‘ts’ ], moduleNameMapper: { ‘^@/(.*)$’: ‘<rootDir>/src/$1’ }, transform: { “.*\\.(vue)$”: “<rootDir>/node_modules/vue-jest”, “^.+\\.(js|jsx)?$”: “<rootDir>/node_modules/babel-jest”, […]

Categories
CSS Development

Jest SyntaxError: Unexpected token . with scss

I got this error when trying to setup Jest with React.js and webpack. Somehow Jest doesnt allow me to import files without define. How shoul I do to solve this issue? The Error ({“Object.”:function(module,exports,require,__dirname,__filename,global,jest){.title { SyntaxError: Unexpected token . import { sampleAction } from ‘../../redux/sample/sample.action’; -> import ‘./landing.styles.scss’; Thank you very much for advance jest.config.js […]