mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-17 02:43:32 +00:00
Configure karma to load angular, requirejs and test/source files
Use test-main.js file to configure requirejs so that AMD loader can be used
This commit is contained in:
parent
0b77e97df2
commit
89c9475d29
2 changed files with 27 additions and 1 deletions
|
@ -10,7 +10,19 @@ module.exports = function (config) {
|
|||
}
|
||||
},
|
||||
browsers: ['ChromeCustom'],
|
||||
files: [],
|
||||
files: [
|
||||
'test/unit_frontend/js/bootstrap.js',
|
||||
// Angular must be loaded before requirejs to set up angular global
|
||||
'public/js/libs/angular-1.6.4.min.js',
|
||||
'public/js/libs/angular-mocks.js',
|
||||
'public/js/libs/jquery-1.11.1.min.js',
|
||||
// Set up requirejs
|
||||
'test/unit_frontend/js/test-main.js',
|
||||
// Include source & test files, but don't "include" them as requirejs
|
||||
// handles this for us
|
||||
{ pattern: 'public/js/**/*.js', included: false },
|
||||
{ pattern: 'test/unit_frontend/js/**/*.js', included: false }
|
||||
],
|
||||
frameworks: ['requirejs', 'mocha', 'chai-sinon'],
|
||||
plugins: [
|
||||
require('karma-requirejs'),
|
||||
|
|
14
services/web/test/unit_frontend/coffee/test-main.coffee
Normal file
14
services/web/test/unit_frontend/coffee/test-main.coffee
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Set up requirejs to load the tests
|
||||
# Uses heuristic that test filenames end with Tests.js
|
||||
tests = []
|
||||
for file of window.__karma__.files
|
||||
if window.__karma__.files.hasOwnProperty(file)
|
||||
if /Tests\.js$/.test(file)
|
||||
tests.push(file)
|
||||
|
||||
requirejs.config
|
||||
baseUrl: '/base/public/js'
|
||||
paths:
|
||||
"moment": "libs/moment-2.9.0"
|
||||
deps: tests
|
||||
callback: window.__karma__.start
|
Loading…
Reference in a new issue