karma-runner / karma-runner/karma
The source js file is not loading.
- Dominant language
- JavaScript
- Stars
- 12k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
### Expected behavior
Import my source files so I can call my functions
### Actual behavior
Got `ReferenceError: app is not defined...` and `Uncaught Error: Script error for "script", needed by: spec/spec` erros
### Enviroment Details
- Karma version: 0.13.22
`karma.config.js`
``` javascript
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine-jquery', 'jasmine', 'requirejs'],
// list of files / patterns to load in the browser
files: [
{pattern: 'lib/*.js', included: false},
{pattern: 'src/*.js', included: false},
{pattern: 'spec/*.js', included: false},
{pattern: 'spec/fixtures/*.html', included: false, served: true},
'spec/test-main.js'
],
```
`test-main.js`
``` javascript
require.config({
// Karma serves files under /base, which is the basePath from your config file
baseUrl: '/base',
paths: {
jquery: 'lib/jquery',
script: 'src/script'
},
// dynamically load all test files
deps: allTestFiles,
```
`spec.js`
``` javascript
define(['script', 'jquery'], function(app, $) {
describe('some test that needs a fixture', function(){
beforeEach(function(){
jasmine.getFixtures().fixturesPath = 'base/spec/fixtures';
loadFixtures('test1.html');
console.log(app); //log undefined
});
it('plays with the html fixture', function(){
expect(app).toBeDefined();
});
});
});
```
`WorkingTree`

Contributor guide
Assessment
This issue has not been assessed yet.