Integration of Foundation-Apps Angular website with unit testing using Karma-Jasmine

While attempting to run a karma jasmine unit test, I encountered an issue with using angular-mocks and foundation-apps. It's possible that I overlooked something in my setup. I've provided an example project on github for further evaluation due to the extensive amount of code involved.

Although the site functions correctly and karma successfully runs the test, upon debugging into the angular.mocks.module function, it appears that the module from my app is not being loaded.

Removing foundation-apps resolves the issue. Could this be a result of a version conflict, perhaps due to foundation-apps having an older dependency for angular-mocks?

fatest on github

Answer №1

I encountered the same issue and resolved it by including the generated CSS file (app.css - created using the sass task) in the karma configuration. Without this file, I received the following error:

TypeError: 'null' is not an object (evaluating 'mediaQueries[key].replace')

Below is the snippet from my gulp configuration:

var karma = require('karma').server;
//...........//
// Compiling Sass
gulp.task('sass', function () {
  return gulp.src('client/assets/scss/app.scss')
    .pipe(plugins.sass({
      includePaths: paths.sass,
      outputStyle: (isProduction ? 'compressed' : 'nested'),
      errLogToConsole: true
    }))
    .pipe(plugins.autoprefixer({browsers: ['last 2 versions', 'ie 10']}))
    .pipe(gulp.dest('./build/assets/css/'))
    .pipe(plugins.livereload());
  });
/// ..... some other things here ......///
gulp.task('unit-test', function (done) {
  var testFiles = [          
          {pattern:'./build/assets/js/foundation.js',watched:false},
          {pattern:'./build/assets/js/routes.js',watched:false},
          {pattern:'./build/assets/css/app.css',watched:false},
          {pattern:'./build/assets/js/templates.js',watched:false},
          {pattern:'./bower_components/angular-mocks/angular-mocks.js', watched:false},
          {pattern:'./client/assets/js/*.js'},
          {pattern:'./client/templates/**/*.js'}                  
    ];

    karma.start({
            configFile:__dirname + '/karma.conf.js',
            singleRun: true,
            files: testFiles
        }, done);   
});

If your application is already built, simply execute gulp unit-test.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue "cannot update headers after they have been sent"

I've been working on a node.js application to retrieve movie listings using the omdb api. However, I'm encountering an error when attempting to access the /result route. The error message is as follows: Error: Can't set headers after they ar ...

Re-calculating with Jquery when input is updated

I am looking for guidance on how to make the calculator recalculate based on a change in the #calcTotal input field. I have successfully calculated all fields and managed to update the #cwac field when one of the values before it changes. Here is the HTML ...

How can I retrieve the value of $_POST[] immediately after a selection is made in a dropdown box

Is there a way to retrieve the $_POST value immediately after changing the select option without having to submit the form? <select name="cat_id" class="form-control" onChange="this.form.submit();" style="width:300px;"> <?php ...

Chrome is blocking my ajax cross-origin request, causing it to be cancelled

I have been working on a Google Chrome extension and encountering an issue with my ajax requests. Every time my extension sends a request, it ends up getting cancelled for some unknown reason. The following code snippet seems to be functioning properly: ...

What is the designated color for highlighting an option in Next.js?

This is my first time working on a Next.js project and I see an unfamiliar option. Which selection should I choose? I plan to use JavaScript for the Next.js project, not TypeScript. Just need to figure out which option is currently selected so I can pro ...

What is the best way to transfer an ag-grid table using nodejs?

Within my webpage, I utilize the AG-GRID library to dynamically generate a table in the backend and create a corresponding JS file. This file is then called from the frontend where Handlebars is employed for rendering. Thus far, the code functions as inten ...

Express and Webpack Error: "SyntaxError: Unexpected token <"

I am facing difficulties while testing my React webpage that I built using Webpack. When trying to run an Express server, the localhost page appears blank with a console message saying Uncaught SyntaxError: Unexpected token <. It seems like the webpage ...

What is an alternative way to display static images in Rails 5 without relying on the Asset Pipeline?

I developed a web-based application with the backend built on Rails 5. Utilizing AngularJS for the frontend, I opted to not use the Asset Pipeline to deliver static content. Instead, I loaded all my scripts (JS & CSS) in the index.html file located within ...

Tips for accessing the value stored within the parent element

As someone who is new to the world of javascript and typescript, I am currently working on an ionic application that involves fetching a list of values from a database. These values are then stored in an array, which is used to dynamically create ion-items ...

Incorporate JSON information into a sleek Bootstrap modal interface

I am looking to load a JSON file to generate a list within a Bootstrap Modal. The setup I have allows for the modal to appear when clicking on a person's image. <li class="project span3" data-type="pfa"> <a data-toggle="modal" data-targe ...

Matching an element that contains a specific string in JS/CSS

I'm currently faced with an HTML file that's being generated by an outdated system, making it tricky for me to control the code generation process. The structure of the HTML code is as follows: <table cellpadding=10> <tr> ...

Displaying the second image twice in a jQuery image slider

When attempting to implement a slider on my website, I encountered an issue where the second image appears twice in a row before the slider starts working as expected. I'm struggling to figure out why this is happening. Here is the jQuery code I am u ...

Continuously decrease a sequence of identical numbers in an array through recursion

One of the key challenges was to condense an array of numbers (with consecutive duplicates) by combining neighboring duplicates: const sumClones = (numbers) => { if (Array.isArray(numbers)) { return numbers.reduce((acc, elem, i, arr) => { if ( ...

Guide to creating a key-value pair from an array

Here is the JSON data: [["123", "456", "789", "user1"], ["987", "654", "321", "user2"]] In my code, I stored it like this: var rows = [ ["123","456","789","user1"] , ["987","654","321","user2"] ]; I am trying to figure out how to create key-value ...

Having trouble putting Protractor to "rest"

Having trouble getting Protractor to rest. I have the following line in my spec file: browser.driver.sleep(5000); I've experimented with different solutions, but none of them seem to be effective.. Your assistance is greatly appreciated. ...

I encountered an error in the Expo dashboard when attempting to upgrade from version 48 to 49 during the Expo Expo version change

For the image description, type in: "expo": "49", "react-native-reanimated": "~3.3.0", "expo-updates": "~0.18.19" I need assistance, can someone please help me out? ...

What is the best way to pass data between sibling components using services?

I'm looking to connect a service to a component that can fetch data, share objects, and communicate with other components that are already linked to the database. I've established a service named DashService as follows: import { Injectable } fro ...

Is there a clear explanation for why the child nodes of my breeze entity are refusing to expand?

I can't seem to understand why my child nodes are showing up as either null or having a count of 0, when there is definitely relevant data in the database. The parent class here is "Project" public partial class Project { public Project() p ...

Verify if a selection of days using momentjs exceeds 7 days

Is there a way to determine if more than 7 days have been selected on the calendar? I need to disable a button based on this condition. fromDate and toDate are global variables where I store dates from the calendar. Feeling a little confused at the moment ...

Rotating objects with Three.js on mobile devices

I came across a related question on Stack Overflow about stopping automatic rotation in Three.js while the mouse is clicked. I am now attempting to achieve the same functionality for rotating an object on smartphones and tablets. Given that I have curren ...