karma-webpack

Webpack directory appended at error after migrating to Angular9

雨燕双飞 提交于 2020-06-13 05:28:26
问题 I've recently upgraded my projet from angular 7 to angular 9. When I run the tests ( ng test ), I always get http://localhost:9876/_karma_webpack_/ appendend to the error, hence in visual studio code, we can't click on the error to got directly to the file. For the sake of testing, I've added expect(2).toEqual(1); in the app.component.spec.ts file For example, with the angular 7 projet out of the box, I get this error with ng test: Chrome 81.0.4044 (Windows 10.0.0) AppComponent should have as

How to test two returned functions with different argument value in javascript?

亡梦爱人 提交于 2020-01-16 18:00:33
问题 I have a function that returns comparisonFunction getComparisonFunction(propertyOfComparison) { const func = function(a, b){ if ( a[propertyOfComparison] < b[propertyOfComparison] ) { return -1; } if ( a[propertyOfComparison] > b[propertyOfComparison] ) { return 1; } return 0; }; return func; } This method will be used inside javascript "sort" method. for example: arrayOfObjects.sort(getComparisonFunction('name')); This method will sort "arrayOfObjects" by "name" property. Method works fine,

karma-webpack : Module name has not been loaded yet for context : use require([])

怎甘沉沦 提交于 2020-01-05 04:16:06
问题 I'm new to Jasmine/Karma unit testing for JavaScript applications. I'm trying to implement it in my current project which is using Angular 1.4.12 and Webpack 1.13.1 for bundling. My folder structure is as follows: The index.js file inside 'core' is trying to require various other modules which are required for Webpack bundling. The file looks like this: require('../../bower_components/font-awesome/css/font-awesome.min.css'); require('../../bower_components/bootstrap/dist/css/bootstrap.min.css

Karma-webpack+angular TypeError: undefined is not an object (evaluating '$httpBackend.expectPOST'

半腔热情 提交于 2020-01-02 14:36:08
问题 I got the following error PhantomJS 2.1.1 (Linux 0.0.0) leave API service create(): should create a leave FAILED static/app.min.js:4804:54 forEach@static/app.min.js:440:25 loadModules@static/app.min.js:4764:13 createInjector@static/app.min.js:4686:31 WorkFn@node_modules/angular-mocks/angular-mocks.js:3120:60 loaded@http://localhost:9876/context.js:151:17 TypeError: undefined is not an object (evaluating '$httpBackend.expectPOST') in test/leave.service.tests.js (line 65) test/leave.service

Karma Test With angular 6

社会主义新天地 提交于 2019-12-23 16:43:41
问题 I am tring to run test of angular using npm ng test but the problem is that chrome start and not stop after test finish so I used : ng test --watch=false but that cause error "Chrome 69.0.3497 (Linux 0.0.0) ERROR" which make chrome timeout I am trying to run that on continuous deployment server so this error cause fail in the process any idea how to stop that 回答1: You can avoid this under unix based system using the Headless chrome It's a way to run the Chrome browser in a headless

Karma Webpack sourcemaps not working

喜夏-厌秋 提交于 2019-12-20 11:20:39
问题 I'm using Karma-Webpack to run my Angular 2 specs. https://github.com/webpack/karma-webpack When I execute tests using karma in Chrome, the source files for my specs appear readable in the debugger. However, the system under test files (my application source) is unreadable. I'm using the karma-sourcemap-loader and have devtool set to 'inline-source-map' as instructed. What could be causing this problem? This build is modeled after the AngularClass angular2-webpack-starter. https://github.com

Karma Webpack Jasmine Unit Testing not working

牧云@^-^@ 提交于 2019-12-11 08:51:50
问题 I am trying to setup testing with Karma, Jasmine, Webpack in AngularJS. My webpack is working fine and I can run my website using npm start A simple test works fine but the moment I try to add my app.js everything goes downhill. I have tried many many many searches and many solutions. Please dont think, I am writing this question the moment I hit a deadend. I have spent all day today just googling and find possible solutions. There is my karma.conf.js file // Karma configuration // Generated

Karma not running tests that have “import” statements in karma-webpack

我的梦境 提交于 2019-12-10 13:21:46
问题 I have some test files with tests I'd like to run against my app. I am attempting to use karma , karma-webpack , karma-babel-preprocessor , karma-chrome-launcher , and jasmine in my testing. My app depends on many things, including backbone , marionette , etc. My app is built using webpack , and I am attempting to use webpack to bundle my files together for testing. (I initially wanted to see if I could skip this step, i.e. simply import a file to be tested, but it seems this is impossible.)

Karma-webpack+angular TypeError: undefined is not an object (evaluating '$httpBackend.expectPOST'

≡放荡痞女 提交于 2019-12-06 13:59:43
I got the following error PhantomJS 2.1.1 (Linux 0.0.0) leave API service create(): should create a leave FAILED static/app.min.js:4804:54 forEach@static/app.min.js:440:25 loadModules@static/app.min.js:4764:13 createInjector@static/app.min.js:4686:31 WorkFn@node_modules/angular-mocks/angular-mocks.js:3120:60 loaded@http://localhost:9876/context.js:151:17 TypeError: undefined is not an object (evaluating '$httpBackend.expectPOST') in test/leave.service.tests.js (line 65) test/leave.service.tests.js:65:16 loaded@http://localhost:9876/context.js:151:17 Test var chai = require('chai'); var assert

Is it possible to transpile local modules from node_module?

心不动则不痛 提交于 2019-12-04 13:05:49
I have 2 typescript projects which contain few classes. I have added Project1's dependency in the Project2 in package.json { "name": "Project2", "dependencies": { "@Project1": "file:../Project1/dist" } } Both the project are built using "target": "es5", "module": "es2015", I am using Karma-Webpack for setting up test environment for the projects. To transpile the code I have used babel-loader (with preset: es2015) instead of ts-loader. It transpiles the code from the Project2 but the code from Project1 located in node_modules is not getting transpiled. Due to that it throws below error when