Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Script Error from requireJS #600

Closed
TKTheTechie opened this issue Jun 25, 2013 · 4 comments
Closed

Error: Script Error from requireJS #600

TKTheTechie opened this issue Jun 25, 2013 · 4 comments

Comments

@TKTheTechie
Copy link

Hi,

I'm trying to run karma on my project with requireJS and I followed the instructions on this project but when attempting to run my project - I get a script error from requireJS:

Error: Script error
http://requirejs.org/docs/errors.html#scripterror
at http://localhost:9876/adapter/lib/require.js?1372089132000:1746

I'm not sure what to do here.. any ideas.

Here is my karma debug output -

<!doctype html>
<!--
This file is almost the same as context.html - loads all source files,
but it's purpose is to be loaded in the main frame (not within an iframe),
just for immediate execution, without reporting to Testacular server.
-->
<html>
<head>
  <title>Karma DEBUG RUNNER</title>
  <!-- TOOD(vojta): create simple favicon and cache it -->
  <link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
  <!-- The scripts need to be at the end of body, so that some test running frameworks
   (Angular Scenario, for example) need the body to be loaded so that it can insert its magic
   into it. If it is before body, then it fails to find the body and crashes and burns in an epic
   manner. -->
  <script type="text/javascript">
    window.__karma__ = {
      info: function(info) {
        if (info.dump && window.console) window.console.log(info.dump);
      },
      complete: function() {},
      store: function() {},
      result: window.console ? function(result) {
        if (result.skipped) return;
        var msg = result.success ? 'SUCCESS ' : 'FAILED ';
        window.console.log(msg + result.suite.join(' ') + ' ' + result.description);
      } : function() {},
      loaded: function() {
        this.start();
      }
    };

    // All served files with the latest timestamps
    window.__karma__.files = {
  '/adapter/lib/jasmine.js': '1372089132000',
  '/adapter/jasmine.js': '1372089132000',
  '/adapter/lib/require.js': '1372089132000',
  '/adapter/require.js': '1372089132000',
  '/absoluteC:/myApp/src/main/webapp/components/angular-1.0.7.js': '1371493150000',
  '/absoluteC:/myApp/src/main/webapp/components/angular-1.0.7.min.js': '1371493150000',
  '/absoluteC:/myApp/src/main/webapp/components/angular-mocks.js': '1372130334000',
  '/absoluteC:/myApp/src/main/webapp/components/angular.js': '1371493150000',
  '/absoluteC:/myApp/src/main/webapp/components/angular.min.js': '1371493150000',
  '/absoluteC:/myApp/src/main/webapp/components/bootstrap/js/bootstrap-datepicker.js': '1372096421000',
  '/absoluteC:/myApp/src/main/webapp/components/bootstrap/js/bootstrap.js': '1370468989000',
  '/absoluteC:/myApp/src/main/webapp/components/bootstrap/js/bootstrap.min.js': '1370468989000',
  '/absoluteC:/myApp/src/main/webapp/components/jquery-ui.js': '1372184670000',
  '/absoluteC:/myApp/src/main/webapp/components/jquery.js': '1372184670000',
  '/absoluteC:/myApp/src/main/webapp/components/jquery.min.js': '1370468989000',
  '/absoluteC:/myApp/src/main/webapp/components/lodash.js': '1370468989000',
  '/absoluteC:/myApp/src/main/webapp/components/require.js': '1370468989000',
  '/absoluteC:/myApp/src/main/webapp/components/underscore-min.js': '1372184815000',
  '/absoluteC:/myApp/src/main/webapp/js/controllers/overviewctrl.js': '1372184670000',
  '/absoluteC:/myApp/src/main/webapp/js/controllers/topicactivityctrl.js': '1372096421000',
  '/absoluteC:/myApp/src/main/webapp/js/helper.js': '1372184670000',
  '/absoluteC:/myApp/src/main/webapp/js/mcc.js': '1372184670000',
  '/absoluteC:/myApp/src/main/webapp/js/services/subjectmodel.js': '1372184670000',
  '/absoluteC:/myApp/src/main/webapp/js/services/transportmodel.js': '1372184670000',
  '/base/unit/sampleTest.js': '1372195990000',
  '/base/unit/test-main.js': '1372195358000'
};

  </script>
  <!-- Dynamically replaced with <script> tags -->
  <script type="text/javascript" src="/adapter/lib/jasmine.js"></script>
<script type="text/javascript" src="/adapter/jasmine.js"></script>
<script type="text/javascript" src="/adapter/lib/require.js"></script>
<script type="text/javascript" src="/adapter/require.js"></script>
<script type="text/javascript" src="/base/unit/test-main.js"></script>
  <script type="text/javascript">
    window.__karma__.loaded();
  </script>
</body>
</html>

Karma-conf

// Karma configuration
// Generated on Mon Jun 24 2013 11:20:44 GMT-0400 (Eastern Daylight Time)


// base path, that will be used to resolve files and exclude
basePath = '.';


// list of files / patterns to load in the browser
files = [
  JASMINE,
  JASMINE_ADAPTER,
  REQUIRE,
  REQUIRE_ADAPTER,
  {pattern: '../components/**/*.js', included:false},
  {pattern: '../js/**/*.js', included:false},
  {pattern: 'unit/*Test.js', included:false},
   'unit/test-main.js'
];


// list of files to exclude
exclude = [
   'server.js',
   'karma.conf.js'

];




// test results reporter to use
// possible values: 'dots', 'progress', 'junit'
reporters = ['progress'];


// web server port
port = 9876;


// cli runner port
runnerPort = 9100;


// enable / disable colors in the output (reporters and logs)
colors = true;


// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;


// enable / disable watching file and executing tests whenever any file changes
autoWatch = true;


// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['PhantomJS'];


// If browser does not capture in given timeout [ms], kill it
captureTimeout = 60000;


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;

test-main.js

var tests = [];
for (var file in window.__karma__.files) {
    if (/Test\.js$/.test(file)) {
        tests.push(file);
    }
}

requirejs.config({
    baseUrl: '/base/src',
    paths: {
        'angular': '../components/angular-1.0.7',
        'angular-mocks': '../components/angular-mocks',
        'jquery': '../components/jquery',
        'jquery-ui': '../components/jquery-ui',
        'lodash': '../components/lodash',
        'underscore': '../components/underscore-min',
        'boostrap': '../components/bootstrap',
        'boostrap-datepicker': '../components/bootstrap-datepicker'
    },

    shim: {
        'underscore': {
            exports: '_'
        }
    },

    // ask Require.js to load these files (all our tests)
    deps: tests,

    // start test run, once Require.js is done
    callback: window.__karma__.start
});
@dilipkrish
Copy link

@PocketDealHunter When you get this error, its best to run

# (Depends however you run this)
karma start

# In another window
karma run 

in the browser just check for javascript errors (404 resource not found) in the console. That will give you a clue as to what is missing.

@kimjoar
Copy link
Contributor

kimjoar commented Jun 27, 2013

@PocketDealHunter Usually when I debug Require.js I just run karma start with Chrome set as the browser (instead of PhantomJS) and then press the debug button in Chrome and open the devtools on the network tab. If you refresh the page you can then see which requests fail (i.e. those that give you a Require.js scripterror)

@TKTheTechie
Copy link
Author

Thank you dilip and kjbekkelund, I've found the issue out by looking at chrome debug.

@thomaspons
Copy link

I've got this issue ! How you have resolved it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants