Categories
Mastering Development

How to configure test coverage visualisation in gitlab CICD?

I am trying to configure test coverage visualisation with reference to official documentation(https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html), I tried with the same, but my pipeline failed hence no report is shown on merge requests, Our project stacks are NodeJS – Typescript. For testing we use JEST framework. I tried in many ways, but no luck. can anyone help me […]

Categories
Mastering Development

Vue Jest Invalid or unexpected token

I’m new to Jest and Vue, but I’m getting an error in one of my tests. The error is: Test suite failed to run /…../node_modules/element-ui/lib/theme-chalk/table-column.css:1 ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){@charset "UTF-8";.el-checkbox,.el-checkbox__input{white-space:nowrap;display:inline-block;position:relative}.el-checkbox{color:#606266;font-weight:500;font-size:14px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;margin-right:30px}.el-checkbox.is-bordered{padding:9px 20px 9px 10px;border-radius:4px;border:1px solid #DCDFE6;-webkit-box-sizing:border-box;box-sizing:border-box;line-height:normal;height:40px}.el-checkbox.is-bordered.is-checked{border-color:#409EFF}.el-checkbox.is-bordered.is-disabled{border-color:#EBEEF5;cursor:not-allowed}.el-checkbox.is-bordered+.el-checkbox.is-bordered{margin-left:10px}.el-checkbox.is-bordered.el-checkbox–medium{padding:7px 20px 7px 10px;border-radius:4px;height:36px}.el-checkbox.is-bordered.el-checkbox–medium .el-checkbox__l SyntaxError: Invalid or unexpected token Here’s my package.json file: "jest": { "moduleFileExtensions": [ "js", "json", "vue" ], "transform": { […]

Categories
Mastering Development

Jest withTypeScript syntaxerror unexpected token, expected “;”

I’ve been trying to setup jest for use with typescript and I’ve tried a bunch of fixes with no luck. I’m getting the error SyntaxError: Unexpected token, expected ";", I think the config isn’t supporting typescript code: https://i.stack.imgur.com/iGBCa.png If anybody has any suggestions I’d be very grateful! Here’s my package.json: "jest": { "preset": "ts-jest", "testEnvironment": […]

Categories
Mastering Development

NestJS Testing: decorator is not a function

My dependencies: "@nestjs/common": "7.4.4", "@nestjs/core": "7.4.4", "typescript": "4.0.2", "jest": "26.4.2", "jest-junit": "11.1.0", "ts-jest": "26.3.0", I have a custom decorator: import { Inject } from "@nestjs/common"; import { DATABASE_SERVICE } from "./database.constants"; export const InjectDatabase = () => Inject(DATABASE_SERVICE); I use it in constructor for a service I’m willing to cover with tests: import { DatabaseService, […]

Categories
Mastering Development

Using VSCode Debugger for Jest Tests throws error “SyntaxError: Cannot use import statement outside a module”

I have tried so many things, that i might just be making it worse at this stage. There are a lot of related questions, but nothing fixes my issue. I am obviously doing something wrong. I want to use VSCode debugger with my Jest Tests. I had this working when I was using require & […]

Categories
Development

ts-jest: map ‘@’ char to /src folder

I have a node project with typescript, and I have the following paths configured in my tsconfig.json file: “paths”: { /* A series of entries which re-map imports to lookup locations relative to the ‘baseUrl’. */ “@project/*”: [“./../*”], “@*”: [“./*”], }, My config files are at /project folder, and my sources at /project/src It works […]