Karma error 'No timestamp for'

Trying to get karma to work with requirejs. I do not understand why I get all these errors when starting Karma:

ERROR: 'There is no timestamp for /base/test/mainSpec.js?bust=1387739317116!' ERROR: 'There is no timestamp for /base/app/main.js?bust=1387739317116!' ERROR: 'There is no timestamp for /base/bower_components/jquery/jquery.js?bust=1387739317116!' 

When I go to the network tab in the inspector, all the files are there without 404s.

I'm a little confused because karma seems to be looking for a β€œbase” directory, but there is no β€œbase” directory in my project. According to the documents of karma:

Karma maintains files in the / base directory. So, on the server, file requests will be http://localhost:9876/base/* . The Require.js configuration for baseUrl gives the initial context for modules that load with relative paths. when setting this value for the Karma server, he will need to start with / base. We want baseUrl for our tests to be the same folder as the base url that we have in src / main.js, so the relative requires in the source will not change. So, since we want our base url to be src /, we need to write / base / src.

This is embarrassing, to say the least. Should I have a baseUrl configuration in the main.js file that points to "/ base"?

+43
requirejs karma-runner
Dec 22 '13 at 19:21
source share
7 answers

note: This message was valid at Karma in 2014 on January 16th. I'm not sure about the current state of this library, maybe they fixed their strange configuration logic and added meaningful error messages. If not, this post can probably be very helpful, fixing configuration problems related to karma.

These errors occur due to incorrect configuration. You must add everything that your test uses to the pattern file in your configuration file.

For example:

 module.exports = function (config) { config.set({ basePath: './', frameworks: ['jasmine', 'requirejs'], files: [ {pattern: 'test/bootstrap.js', included: true}, {pattern: 'test/**/*.js', included: false}, {pattern: 'src/**/*.js', included: false}, {pattern: 'vendor/**/*.js', included: false} ], exclude: [ ], reporters: ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Firefox'], captureTimeout: 6000, singleRun: false }); }; 

In this example, bootstrap.js is the only HTML file included by Karma , other files are dependencies that are loaded by code into bootstrap.js. The order of the templates is very important and, unfortunately, it is far from logical: the next template does not cancel the previous one . Therefore, if I gave the test/**/*.js template as the first and test/bootstrap.js as the second, it would not work because bootstrap would not be included. In these cases, Karma sends you the message "empty testsuite" , which is useless if you do not know how to configure it ...

If your tests try to use a file that is not covered by the templates specified in the Karma configuration file, you will receive the error message "There is no timestamp for xy" , which is very similar to the previous "empty testsuite" . If you do not know the system, you will not have a clue what it means or what you need to do to fix it ...

Part of the exclude object of the configuration object is for files that have been added to file templates for inclusion, but you do not want to include or use them in your tests. These can be, for example, requirejs configuration files for a development and production environment, etc.

+20
Jan 16 '14 at 4:08
source share

For me, it just made a mistake by setting basePath: 'base' instead of baseUrl: '/base' .

baseUrl: '/base' ftw!

+18
May 22 '14 at 5:35
source share

BasePath should identify the root of your project relative to the configuration file (karma.conf.js). Take a look at this example: https://github.com/karma-runner/karma/blob/v0.8.5/test/client/karma.conf.js

In the browser, I also received this error about the timestamp, but it does not affect anything. Tests work correctly. I think this should be a warning more than an error :-)

+3
Dec 22 '13 at 20:53 on
source share

Jeff is right, you should exclude your application's requirejs configuration file because "we don’t want to run the application in our tests. [LINK] ".

The test-main.js configuration file is a separate file from the requirejs configuration file, it is used in your application , which in your case can be config.js or main.js , depending on where you configure your requirements.

They both tweak the path and dependencies (they may point to the same ones), but the first is to provide requirejs support for the tests you write. All this installation requires a separate configuration from the requirements that you use in your application. Therefore, do not include the latter, he confuses Karma.

And the above link is a working Karma with a demonstration of its requirejs, check it out.

+2
Jun 23 '14 at 9:01
source share

After trying all the solutions posted in different sources, Finally, I got a fix . Check it out here: Configuring the "no timestamp" error # 6 .

An example of a problem for the karma.conf.js file:

 client: { requireJsShowNoTimestampsError: '^(?!.*(^/base/app/node_modules/))' } 
+2
Jul 17 '14 at 8:33
source share

in my karma.conf.js file, I just excluded my file containing my require.config function (in my case it was the config.js file) and the errors went away.

  exclude: [ 'app/config.js', 'bower_components/jasmine/**/*.js' ], 
+1
Dec 22 '13 at 22:33
source share

This error can also occur if the files in question do not actually exist!

So make sure that the file you get this error really exists in your project!

Once you know which files are, you can ignore them using a template similar to this in your karma.conf.js , if in some cases its existence should be ignored:

exclude: [ 'path/to/files/to/ignore/**/*.js' ]

0
May 16 '16 at 17:37
source share



All Articles