Code Monkey home page Code Monkey logo

Comments (5)

inorganik avatar inorganik commented on September 13, 2024 3

I was able to reproduce, I'll see what I can figure out

from ngx-countup.

inorganik avatar inorganik commented on September 13, 2024 3

Ok, I got it working. Also I pushed up my changes in the test app included in this repo, so it has a passing test with Jest, as well as a new section in the README.

For Jest, make sure you have the following in your jest.config.js:

transform: {
  '^.+\\.(js|ts|tsx)$': 'ts-jest'
},
transformIgnorePatterns: ['node_modules/(?!countup.js)']

Also! In your root tsconfig.json, add

    "allowJs": true,

under compilerOptions

from ngx-countup.

ramonferreiradev avatar ramonferreiradev commented on September 13, 2024 1

Hi Jamie

It works!!!

The only change I had to make was to remove the "transform". For some reason, Jest continued to receive an error if this setting was set.

Thank you for your help.
Regards.

from ngx-countup.

inorganik avatar inorganik commented on September 13, 2024

First make sure you are ignoring node_modules in your jest config:

jest.config.js

module.exports = {
  ...
  transformIgnorePatterns: ['node_modules/(?!(jest-test))'],
};

In the spec file for the component, import CountUpModule:

TestBed.configureTestingModule({
  imports: [ CountUpModule ]
})

That should do it, hopefully that resolves your issue

from ngx-countup.

ramonferreiradev avatar ramonferreiradev commented on September 13, 2024

Hi, Jamie.

I tried this config but doesn't work. The Jest continues logging the same error.

Below my package.json where is the Jest configuration

{
...
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "jest --no-cache --coverage",
"tdd": "jest --no-cache --coverage --watch",
"lint": "ng lint",
"e2e": "ng e2e",
"build": "ng build",
"commit": "git-cz"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.2.4",
"@angular/common": "~7.2.4",
"@angular/compiler": "~7.2.4",
"@angular/core": "~7.2.4",
"@angular/elements": "^7.2.4",
"@angular/forms": "~7.2.4",
"@angular/platform-browser": "~7.2.4",
"@angular/platform-browser-dynamic": "~7.2.4",
"@angular/router": "~7.2.4",
"@webcomponents/custom-elements": "^1.2.1",
"@webcomponents/webcomponentsjs": "^2.2.7",
"core-js": "^2.6.4",
"countup.js-angular2": "^7.1.1",
"document-register-element": "^1.13.1",
"ng-lottie": "^0.3.2",
"rxjs": "~6.4.0",
"tiny-slider": "^2.9.1",
"tslib": "^1.9.3",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^7.3.1",
"@angular-devkit/build-angular": "^0.13.8",
"@angular/cli": "^7.3.1",
"@angular/compiler-cli": "^7.2.7",
"@angular/language-service": "~7.2.4",
"@commitlint/cli": "^7.5.2",
"@commitlint/config-conventional": "^7.5.0",
"@types/jest": "^24.0.11",
"@types/node": "~10.12.24",
"@whizark/cz-cli": "^0.7.0",
"codelyzer": "~4.5.0",
"commitizen": "^3.0.7",
"concat": "^1.0.3",
"cz-conventional-changelog": "^2.1.0",
"fs-extra": "^7.0.1",
"git-cz": "^3.0.1",
"husky": "^1.3.1",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"jest": "^24.5.0",
"jest-preset-angular": "^6.0.2",
"protractor": "~5.4.2",
"ts-node": "~8.0.2",
"tslint": "~5.12.1",
"typescript": "3.2.4"
},
"jest": {
"verbose": true,
"coverageDirectory": "dist/test-coverage",
"collectCoverageFrom": [
"**/*.ts"
],
"transformIgnorePatterns": [
"node_modules/(?!@ngrx|angular2-ui-switch|ng-dynamic)",
"node_modules/(?!(jest-test))"
],
"globals": {
"ts-jest": {
"tsConfigFile": "./tsconfig.spec.json"
},
"TRANSFORM_HTML": true
},
"preset": "jest-preset-angular",
"setupFilesAfterEnv": [
"/src/setupJest.ts"
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}

from ngx-countup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.