Commit 8b645754 by Usman Khalid

Merge pull request #12344 from edx/usman/tnl4398-karma-config-improvements

Karma config improvements.
parents db52e033 a2dadeaa
......@@ -27,9 +27,9 @@ requirejs.config({
"moment": "xmodule_js/common_static/js/vendor/moment.min",
"moment-with-locales": "xmodule_js/common_static/js/vendor/moment-with-locales.min",
"text": "xmodule_js/common_static/js/vendor/requirejs/text",
"underscore": "xmodule_js/common_static/common/js/vendor/underscore",
"underscore.string": "xmodule_js/common_static/common/js/vendor/underscore.string",
"backbone": "xmodule_js/common_static/common/js/vendor/backbone",
"underscore": "common/js/vendor/underscore",
"underscore.string": "common/js/vendor/underscore.string",
"backbone": "common/js/vendor/backbone",
"backbone.associations": "xmodule_js/common_static/js/vendor/backbone-associations-min",
"backbone.paginator": "xmodule_js/common_static/js/vendor/backbone.paginator.min",
"backbone-relational": "xmodule_js/common_static/js/vendor/backbone-relational.min",
......@@ -44,15 +44,13 @@ requirejs.config({
"sinon": "xmodule_js/common_static/js/vendor/sinon-1.17.0",
"squire": "xmodule_js/common_static/js/vendor/Squire",
"jasmine-imagediff": "xmodule_js/common_static/js/vendor/jasmine-imagediff",
"jasmine-stealth": "xmodule_js/common_static/js/libs/jasmine-stealth",
"jasmine-waituntil": "xmodule_js/common_static/js/libs/jasmine-waituntil",
"draggabilly": "xmodule_js/common_static/js/vendor/draggabilly",
"domReady": "xmodule_js/common_static/js/vendor/domReady",
"URI": "xmodule_js/common_static/js/vendor/URI.min",
"mock-ajax": "xmodule_js/common_static/js/vendor/mock-ajax",
"modernizr": "xmodule_js/common_static/edx-pattern-library/js/modernizr-custom",
"afontgarde": "xmodule_js/common_static/edx-pattern-library/js/afontgarde",
"edxicons": "xmodule_js/common_static/edx-pattern-library/js/edx-icons",
"modernizr": "edx-pattern-library/js/modernizr-custom",
"afontgarde": "edx-pattern-library/js/afontgarde",
"edxicons": "edx-pattern-library/js/edx-icons",
"mathjax": "//cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-MML-AM_SVG&delayStartupUntil=configured",
"youtube": "//www.youtube.com/player_api?noext",
......@@ -180,10 +178,13 @@ requirejs.config({
exports: "sinon"
},
"jasmine-imagediff": {},
"jasmine-stealth": {
"common/js/spec_helpers/jasmine-extensions": {
deps: ["jquery"]
},
"common/js/spec_helpers/jasmine-stealth": {
deps: ["underscore", "underscore.string"]
},
"jasmine-waituntil": {
"common/js/spec_helpers/jasmine-waituntil": {
deps: ["jquery"]
},
"xblock/core": {
......@@ -283,8 +284,14 @@ while i < testFiles.length
testFiles[i] = '/base/' + testFiles[i] + '.js'
i++
specHelpers = [
'common/js/spec_helpers/jasmine-extensions',
'common/js/spec_helpers/jasmine-stealth',
'common/js/spec_helpers/jasmine-waituntil'
]
# Jasmine has a global stack for creating a tree of specs. We need to load
# spec files one by one, otherwise some end up getting nested under others.
requireSerial testFiles, ->
requireSerial specHelpers.concat(testFiles), ->
# start test run, once Require.js is done
window.__karma__.start()
require ["jquery", "backbone", "coffee/src/main", "common/js/spec_helpers/ajax_helpers",
"jasmine-stealth", "jasmine-waituntil", "jquery.cookie"],
require ["jquery", "backbone", "coffee/src/main", "common/js/spec_helpers/ajax_helpers", "jquery.cookie"],
($, Backbone, main, AjaxHelpers) ->
describe "CMS", ->
it "should initialize URL", ->
......
......@@ -26,7 +26,7 @@ requirejs.config({
"text": "xmodule_js/common_static/js/vendor/requirejs/text",
"underscore": "common/js/vendor/underscore",
"underscore.string": "common/js/vendor/underscore.string",
"backbone": "xmodule_js/common_static/common/js/vendor/backbone",
"backbone": "common/js/vendor/backbone",
"backbone.associations": "xmodule_js/common_static/js/vendor/backbone-associations-min",
"backbone.paginator": "xmodule_js/common_static/js/vendor/backbone.paginator.min",
"tinymce": "xmodule_js/common_static/js/vendor/tinymce/js/tinymce/tinymce.full.min",
......@@ -38,11 +38,9 @@ requirejs.config({
"utility": "xmodule_js/common_static/js/src/utility",
"sinon": "xmodule_js/common_static/js/vendor/sinon-1.17.0",
"squire": "xmodule_js/common_static/js/vendor/Squire",
"modernizr": "xmodule_js/common_static/edx-pattern-library/js/modernizr-custom",
"afontgarde": "xmodule_js/common_static/edx-pattern-library/js/afontgarde",
"edxicons": "xmodule_js/common_static/edx-pattern-library/js/edx-icons",
"jasmine-stealth": "xmodule_js/common_static/js/libs/jasmine-stealth",
"jasmine-waituntil": "xmodule_js/common_static/js/libs/jasmine-waituntil",
"modernizr": "edx-pattern-library/js/modernizr-custom",
"afontgarde": "edx-pattern-library/js/afontgarde",
"edxicons": "edx-pattern-library/js/edx-icons",
"draggabilly": "xmodule_js/common_static/js/vendor/draggabilly",
"domReady": "xmodule_js/common_static/js/vendor/domReady",
"URI": "xmodule_js/common_static/js/vendor/URI.min",
......@@ -160,10 +158,13 @@ requirejs.config({
"sinon": {
exports: "sinon"
},
"jasmine-stealth": {
"common/js/spec_helpers/jasmine-extensions": {
deps: ["jquery"]
},
"common/js/spec_helpers/jasmine-stealth": {
deps: ["underscore", "underscore.string"]
},
"jasmine-waituntil": {
"common/js/spec_helpers/jasmine-waituntil": {
deps: ["jquery"]
},
"xblock/core": {
......@@ -203,8 +204,14 @@ while i < testFiles.length
testFiles[i] = '/base/' + testFiles[i] + '.js'
i++
specHelpers = [
'common/js/spec_helpers/jasmine-extensions',
'common/js/spec_helpers/jasmine-stealth',
'common/js/spec_helpers/jasmine-waituntil'
]
# Jasmine has a global stack for creating a tree of specs. We need to load
# spec files one by one, otherwise some end up getting nested under others.
requireSerial testFiles, ->
requireSerial specHelpers.concat(testFiles), ->
# start test run, once Require.js is done
window.__karma__.start()
......@@ -2,7 +2,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js
"js/collections/textbook", "js/views/show_textbook", "js/views/edit_textbook", "js/views/list_textbooks",
"js/views/edit_chapter", "common/js/components/views/feedback_prompt",
"common/js/components/views/feedback_notification", "common/js/components/utils/view_utils","common/js/spec_helpers/ajax_helpers",
"js/spec_helpers/modal_helpers", "jasmine-stealth"],
"js/spec_helpers/modal_helpers"],
(Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTextbooks, EditChapter, Prompt, Notification, ViewUtils, AjaxHelpers, modal_helpers) ->
describe "ShowTextbook", ->
......
......@@ -5,7 +5,7 @@ define([
'js/views/group_configuration_item', 'js/views/experiment_group_edit', 'js/views/content_group_list',
'js/views/content_group_details', 'js/views/content_group_editor', 'js/views/content_group_item',
'common/js/components/views/feedback_notification', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'common/js/spec_helpers/view_helpers', 'jasmine-stealth'
'common/js/spec_helpers/view_helpers'
], function(
_, Course, GroupConfigurationModel, GroupModel, GroupConfigurationCollection, GroupCollection,
GroupConfigurationDetailsView, GroupConfigurationsListView, GroupConfigurationEditorView,
......
---
# JavaScript test suite description
#
#
# To run all the tests and print results to the console:
#
# js-test-tool run TEST_SUITE --use-firefox
#
# where `TEST_SUITE` is this file.
#
#
# To run the tests in your default browser ("dev mode"):
#
# js-test-tool dev TEST_SUITE
#
test_suite_name: cms
test_runner: jasmine_requirejs
# Path prepended to source files in the coverage report (optional)
# For example, if the source path
# is "src/source.js" (relative to this YAML file)
# and the prepend path is "base/dir"
# then the coverage report will show
# "base/dir/src/source.js"
prepend_path: cms/static
# Paths to library JavaScript files (optional)
lib_paths:
- xmodule_js/common_static/js/vendor/requirejs/require.js
- xmodule_js/common_static/coffee/src/ajax_prefix.js
- xmodule_js/common_static/js/src/utility.js
- xmodule_js/common_static/js/vendor/jquery.min.js
- xmodule_js/common_static/js/vendor/jquery-ui.min.js
- xmodule_js/common_static/js/vendor/jquery.cookie.js
- xmodule_js/common_static/js/vendor/jquery.simulate.js
- xmodule_js/common_static/common/js/vendor/underscore.js
- xmodule_js/common_static/common/js/vendor/underscore.string.js
- xmodule_js/common_static/common/js/vendor/backbone.js
- xmodule_js/common_static/js/vendor/backbone-associations-min.js
- xmodule_js/common_static/js/vendor/backbone.paginator.min.js
- xmodule_js/common_static/js/vendor/backbone-relational.min.js
- xmodule_js/common_static/js/vendor/timepicker/jquery.timepicker.js
- xmodule_js/common_static/js/vendor/jquery.leanModal.js
- xmodule_js/common_static/js/vendor/jquery.ajaxQueue.js
- xmodule_js/common_static/js/vendor/jquery.form.js
- xmodule_js/common_static/js/vendor/html5-input-polyfills/number-polyfill.js
- xmodule_js/common_static/js/vendor/sinon-1.17.0.js
- xmodule_js/common_static/js/vendor/Squire.js
- xmodule_js/common_static/js/libs/jasmine-stealth.js
- xmodule_js/common_static/js/libs/jasmine-waituntil.js
- xmodule_js/common_static/js/vendor/jasmine-imagediff.js
- xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js
- xmodule_js/src/xmodule.js
- xmodule_js/common_static/js/test/i18n.js
- xmodule_js/common_static/js/vendor/draggabilly.js
- xmodule_js/common_static/js/vendor/date.js
- xmodule_js/common_static/js/vendor/domReady.js
- xmodule_js/common_static/js/vendor/URI.min.js
- xmodule_js/common_static/js/vendor/jquery.smooth-scroll.min.js
- xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js
- xmodule_js/common_static/js/xblock/
- xmodule_js/common_static/coffee/src/xblock/
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.iframe-transport.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js
- xmodule_js/common_static/js/vendor/mock-ajax.js
- xmodule_js/common_static/js/vendor/requirejs/text.js
- xmodule_js/common_static/edx-pattern-library/js/modernizr-custom.js
- xmodule_js/common_static/edx-pattern-library/js/afontgarde.js
- xmodule_js/common_static/edx-pattern-library/js/edx-icons.js
# Paths to source JavaScript files
src_paths:
- coffee/src
- js
- js/certificates
- js/factories
- common/js
- edx-pattern-library/js
- edx-ui-toolkit/js
# Paths to spec (test) JavaScript files
# We should define the custom path mapping in /coffee/spec/main.coffee as well e.g. certificates etc.
spec_paths:
- coffee/spec/main.js
- coffee/spec
- js/spec
- js/certificates/spec
# Paths to fixture files (optional)
# The fixture path will be set automatically when using jasmine-jquery.
# (https://github.com/velesin/jasmine-jquery)
#
# You can then access fixtures using paths relative to
# the test suite description:
#
# loadFixtures('path/to/fixture/fixture.html');
#
fixture_paths:
- coffee/fixtures
- templates
- common/templates
requirejs:
paths:
main: coffee/spec/main
# Because require.js is responsible for loading all dependencies, we exclude
# all files from being included in <script> tags
exclude_from_page:
- .*
---
# JavaScript test suite description
#
#
# To run all the tests and print results to the console:
#
# js-test-tool run TEST_SUITE --use-firefox
#
# where `TEST_SUITE` is this file.
#
#
# To run the tests in your default browser ("dev mode"):
#
# js-test-tool dev TEST_SUITE
#
test_suite_name: cms-squire
test_runner: jasmine_requirejs
# Path prepended to source files in the coverage report (optional)
# For example, if the source path
# is "src/source.js" (relative to this YAML file)
# and the prepend path is "base/dir"
# then the coverage report will show
# "base/dir/src/source.js"
prepend_path: cms/static
# Paths to library JavaScript files (optional)
lib_paths:
- xmodule_js/common_static/js/vendor/requirejs/require.js
- xmodule_js/common_static/coffee/src/ajax_prefix.js
- xmodule_js/common_static/js/src/utility.js
- xmodule_js/common_static/js/vendor/jquery.min.js
- xmodule_js/common_static/js/vendor/jquery-ui.min.js
- xmodule_js/common_static/js/vendor/jquery.cookie.js
- xmodule_js/common_static/common/js/vendor/underscore.js
- xmodule_js/common_static/common/js/vendor/underscore.string.js
- xmodule_js/common_static/common/js/vendor/backbone.js
- xmodule_js/common_static/js/vendor/backbone-associations-min.js
- xmodule_js/common_static/js/vendor/backbone.paginator.min.js
- xmodule_js/common_static/js/vendor/timepicker/jquery.timepicker.js
- xmodule_js/common_static/js/vendor/jquery.leanModal.js
- xmodule_js/common_static/js/vendor/jquery.form.js
- xmodule_js/common_static/js/vendor/html5-input-polyfills/number-polyfill.js
- xmodule_js/common_static/js/vendor/sinon-1.17.0.js
- xmodule_js/common_static/js/vendor/Squire.js
- xmodule_js/common_static/js/vendor/jasmine-imagediff.js
- xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js
- xmodule_js/common_static/js/vendor/domReady.js
- xmodule_js/common_static/js/vendor/URI.min.js
- xmodule_js/src/xmodule.js
- xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js
- xmodule_js/common_static/js/test/i18n.js
- xmodule_js/common_static/js/xblock/
- xmodule_js/common_static/coffee/src/xblock/
- xmodule_js/common_static/js/vendor/URI.min.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.iframe-transport.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js
- xmodule_js/common_static/js/vendor/requirejs/text.js
# Paths to source JavaScript files
src_paths:
- coffee/src
# We don't include all of js because the Javascript files in js/i18n cause issues with the Squire tests.
- js/collections
- js/models
- js/utils
- js/views
- common/js
- edx-pattern-library/js
- edx-ui-toolkit/js
# Paths to spec (test) JavaScript files
spec_paths:
- coffee/spec/main.js
- coffee/spec
- js/spec
# Paths to fixture files (optional)
# The fixture path will be set automatically when using jasmine-jquery.
# (https://github.com/velesin/jasmine-jquery)
#
# You can then access fixtures using paths relative to
# the test suite description:
#
# loadFixtures('path/to/fixture/fixture.html');
#
fixture_paths:
- coffee/fixtures
- templates
- common/templates
requirejs:
paths:
main: coffee/spec/main_squire
# Because require.js is responsible for loading all dependencies, we exclude
# all files from being included in <script> tags
exclude_from_page:
- .*
// Common JavaScript tests, using RequireJS.
//
// To run all the tests and print results to the console:
//
// karma start cms/static/karma_cms.conf.js
//
//
// To run the tests for debugging: Debugging can be done in any browser
// but Chrome's developer console debugging experience is best.
//
// karma start cms/static/karma_cms.conf.js --browsers=BROWSER --single-run=false
//
//
// To run the tests with coverage and junit reports:
//
// karma start cms/static/karma_cms.conf.js --browsers=BROWSER --coverage
// --junitreportpath=<xunit_report_path> --coveragereportpath=<report_path>
//
// where `BROWSER` could be Chrome or Firefox.
//
// Karma config for cms suite.
// Docs and troubleshooting tips in common/static/common/js/karma.common.conf.js
/* jshint node: true */
/*jshint -W079 */
'use strict';
var path = require('path');
var _ = require('underscore');
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
var libraryFiles = [
{pattern: 'xmodule_js/common_static/coffee/src/ajax_prefix.js', included: false},
{pattern: 'xmodule_js/common_static/js/src/utility.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery-ui.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.cookie.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.simulate.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.string.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/vendor/backbone.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/backbone-associations-min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/backbone.paginator.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/backbone-relational.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/timepicker/jquery.timepicker.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.leanModal.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.ajaxQueue.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.form.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/html5-input-polyfills/number-polyfill.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/sinon-1.17.0.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/Squire.js', included: false},
{pattern: 'xmodule_js/common_static/js/libs/jasmine-stealth.js', included: false},
{pattern: 'xmodule_js/common_static/js/libs/jasmine-waituntil.js', included: false},
{pattern: 'xmodule_js/common_static/js/libs/jasmine-extensions.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jasmine-imagediff.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/**/*.js', included: false},
{pattern: 'xmodule_js/src/xmodule.js', included: false},
{pattern: 'xmodule_js/common_static/js/test/i18n.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/draggabilly.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/date.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/domReady.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/URI.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.smooth-scroll.min.js', included: false},
{pattern: 'xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js', included: false},
{pattern: 'xmodule_js/common_static/js/xblock/**/*.js', included: false},
{pattern: 'xmodule_js/common_static/coffee/src/xblock/**/*.js', included: false},
{
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.iframe-transport.js',
included: false
},
{pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload.js', included: false},
{
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process.js',
included: false
},
{
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js',
included: false
},
{pattern: 'xmodule_js/common_static/js/vendor/mock-ajax.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/text.js', included: false},
{pattern: 'edx-ui-toolkit/js/utils/global-loader.js', included: false},
{pattern: 'edx-pattern-library/js/modernizr-custom.js', included: false},
{pattern: 'edx-pattern-library/js/afontgarde.js', included: false},
{pattern: 'edx-pattern-library/js/edx-icons.js', included: false},
{pattern: 'edx-pattern-library/js/**/*.js', included: false},
{pattern: 'edx-ui-toolkit/js/**/*.js', included: false},
var options = {
{pattern: 'common/js/utils/require-serial.js', included: true}
];
includeCommonFiles: true,
// Paths to source JavaScript files
var sourceFiles = [
{pattern: 'coffee/src/**/!(*spec).js', included: false},
{pattern: 'js/**/!(*spec).js', included: false},
{pattern: 'common/js/**/!(*spec).js', included: false}
];
libraryFiles: [],
// Paths to spec (test) JavaScript files
var specFiles = [
{pattern: 'coffee/spec/**/*spec.js', included: false},
{pattern: 'js/spec/**/*spec.js', included: false},
{pattern: 'js/certificates/spec/**/*spec.js', included: false}
];
// Make sure the patterns in sourceFiles and specFiles do not match the same file.
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
sourceFiles: [
{pattern: 'coffee/src/**/!(*spec).js'},
{pattern: 'js/**/!(*spec|djangojs).js'}
],
// Paths to fixture files
var fixtureFiles = [
{pattern: 'coffee/fixtures/**/*.underscore', included: false},
{pattern: 'templates/**/*.underscore', included: false},
{pattern: 'common/templates/**/*.underscore', included: false}
];
specFiles: [
{pattern: 'coffee/spec/**/*spec.js'},
{pattern: 'js/certificates/spec/**/*spec.js'},
{pattern: 'js/spec/**/*spec.js'}
],
// override fixture path and other config.
var runAndConfigFiles = [
{pattern: path.join(configModule.appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true},
'coffee/spec/main.js'
];
fixtureFiles: [
{pattern: 'coffee/fixtures/**/*.underscore'},
{pattern: 'templates/**/*.underscore'}
],
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
runFiles: [
{pattern: 'coffee/spec/main.js', included: true}
]
};
module.exports = function (config) {
var commonConfig = configModule.getConfig(config),
files = _.flatten([libraryFiles, sourceFiles, specFiles, fixtureFiles, runAndConfigFiles]),
localConfig;
// add nocache in files if coverage is not set
if (!config.coverage) {
files.forEach(function (f) {
if (_.isObject(f)) {
f.nocache = true;
}
});
}
localConfig = {
files: files,
preprocessors: preprocessors
};
config.set(_.extend(commonConfig, localConfig));
configModule.configure(config, options);
};
// Common JavaScript tests, using RequireJS.
//
// To run all the tests and print results to the console:
//
// karma start cms/static/karma_cms_squire.conf.js
//
//
// To run the tests for debugging: Debugging can be done in any browser
// but Chrome's developer console debugging experience is best.
//
// karma start cms/static/karma_cms_squire.conf.js --browsers=BROWSER --single-run=false
//
//
// To run the tests with coverage and junit reports:
//
// karma start cms/static/karma_cms_squire.conf.js --browsers=BROWSER --coverage
// --junitreportpath=<xunit_report_path> --coveragereportpath=<report_path>
//
// where `BROWSER` could be Chrome or Firefox.
//
// Karma config for cms-squire suite.
// Docs and troubleshooting tips in common/static/common/js/karma.common.conf.js
/* jshint node: true */
/*jshint -W079 */
'use strict';
var path = require('path');
var _ = require('underscore');
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
var libraryFiles = [
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/require.js', included: false},
{pattern: 'xmodule_js/common_static/coffee/src/ajax_prefix.js', included: false},
{pattern: 'xmodule_js/common_static/js/src/utility.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery-ui.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.cookie.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.string.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/vendor/backbone.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/backbone-associations-min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/backbone.paginator.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/timepicker/jquery.timepicker.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.leanModal.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.form.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/html5-input-polyfills/number-polyfill.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/sinon-1.17.0.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/Squire.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jasmine-imagediff.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/domReady.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/URI.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/libs/jasmine-extensions.js', included: true},
{pattern: 'xmodule_js/src/xmodule.js', included: false},
{pattern: 'xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js', included: false},
{pattern: 'xmodule_js/common_static/js/test/i18n.js', included: false},
{pattern: 'xmodule_js/common_static/js/xblock/**/*.js', included: false},
{pattern: 'xmodule_js/common_static/coffee/src/xblock/**/*.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/URI.min.js', included: false},
{
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.iframe-transport.js',
included: false
},
{pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload.js', included: false},
{
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process.js',
included: false
},
{
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js',
included: false
},
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/text.js', included: false},
{pattern: 'common/js/utils/require-serial.js', included: true}
];
var options = {
// Paths to source JavaScript files
var sourceFiles = [
{pattern: 'coffee/src/**/*.js', included: false},
{pattern: 'js/collections/**/*.js', included: false},
{pattern: 'js/models/**/*.js', included: false},
{pattern: 'js/utils/**/*.js', included: false},
{pattern: 'js/views/**/*.js', included: false},
{pattern: 'common/js/**/*.js', included: false}
];
includeCommonFiles: true,
// Paths to spec (test) JavaScript files
var specFiles = [
{pattern: 'coffee/spec/**/*.js', included: false},
{pattern: 'js/spec/**/*.js', included: false}
];
libraryFiles: [],
// Paths to fixture files
var fixtureFiles = [
{pattern: 'coffee/fixtures/**/*.*', included: false},
{pattern: 'templates/**/*.*', included: false},
{pattern: 'common/templates/**/*.*', included: false}
];
// Make sure the patterns in sourceFiles and specFiles do not match the same file.
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
sourceFiles: [
{pattern: 'coffee/src/**/!(*spec).js'},
{pattern: 'js/**/!(*spec|djangojs).js'}
],
// override fixture path and other config.
var runAndConfigFiles = [
{pattern: path.join(configModule.appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true},
'coffee/spec/main_squire.js'
];
specFiles: [
{pattern: 'coffee/spec/**/*spec.js'},
{pattern: 'js/spec/**/*spec.js'}
],
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
fixtureFiles: [
{pattern: 'coffee/fixtures/**/*.*'},
{pattern: 'templates/**/*.*'}
],
module.exports = function (config) {
var commonConfig = configModule.getConfig(config),
files = _.flatten([libraryFiles, sourceFiles, specFiles, fixtureFiles, runAndConfigFiles]),
localConfig;
// add nocache in files if coverage is not set
if (!config.coverage) {
files.forEach(function (f) {
if (_.isObject(f)) {
f.nocache = true;
}
});
}
localConfig = {
files: files,
preprocessors: preprocessors
};
runFiles: [
{pattern: 'coffee/spec/main_squire.js', included: true}
]
};
config.set(_.extend(commonConfig, localConfig));
module.exports = function (config) {
configModule.configure(config, options);
};
---
# JavaScript test suite description
#
#
# To run all the tests and print results to the console:
#
# js-test-tool run TEST_SUITE --use-firefox
#
# where `TEST_SUITE` is this file.
#
#
# To run the tests in your default browser ("dev mode"):
#
# js-test-tool dev TEST_SUITE
#
test_suite_name: xmodule
test_runner: jasmine
# Path prepended to source files in the coverage report (optional)
# For example, if the source path
# is "src/source.js" (relative to this YAML file)
# and the prepend path is "base/dir"
# then the coverage report will show
# "base/dir/src/source.js"
prepend_path: common/lib/xmodule/xmodule/js
# Paths to source JavaScript files
src_paths:
- src/xmodule.js
- src
# Paths to library JavaScript files (optional)
lib_paths:
- common_static/js/test/i18n.js
- common_static/coffee/src/ajax_prefix.js
- common_static/js/src/logger.js
- common_static/js/vendor/jasmine-imagediff.js
- common_static/js/libs/jasmine-waituntil.js
- common_static/js/vendor/requirejs/require.js
- RequireJS-namespace-undefine.js
- common_static/js/vendor/jquery.min.js
- common_static/js/vendor/jquery-ui.min.js
- common_static/js/vendor/jquery.ui.draggable.js
- common_static/js/vendor/jquery.cookie.js
- common_static/js/vendor/json2.js
- common_static/common/js/vendor/underscore.js
- common_static/common/js/vendor/backbone.js
- common_static/js/vendor/jquery.leanModal.js
- common_static/js/vendor/CodeMirror/codemirror.js
- common_static/js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js
- common_static/js/vendor/tinymce/js/tinymce/tinymce.full.min.js
- common_static/js/vendor/jquery.timeago.js
- common_static/js/vendor/sinon-1.17.0.js
- common_static/js/vendor/analytics.js
- common_static/js/test/add_ajax_prefix.js
- common_static/js/src/utility.js
- public/js/split_test_staff.js
- common_static/js/src/accessibility_tools.js
- common_static/js/vendor/moment.min.js
- common_static/js/vendor/draggabilly.js
- common_static/edx-pattern-library/js/modernizr-custom.js
- common_static/edx-pattern-library/js/afontgarde.js
- common_static/edx-pattern-library/js/edx-icons.js
- spec/main_requirejs.js
# Paths to spec (test) JavaScript files
spec_paths:
- spec/helper.js
- spec
# Paths to fixture files (optional)
fixture_paths:
- fixtures
// Xmodule Tests
//
// To run all the tests and print results to the console:
//
// karma start common/lib/xmodule/xmodule/js/karma_xmodule.conf.js
//
//
// To run the tests for debugging: Debugging can be done in any browser
// Chrome's developer console debugging experience is the best though
//
// karma start common/lib/xmodule/xmodule/js/karma-xmodule.conf.js --browsers=BROWSER --single-run=false
//
//
// To run the tests with coverage and junit reports:
//
// karma start common/lib/xmodule/xmodule/js/karma-xmodule.conf.js
// --browsers=BROWSER --coverage --junitreportpath=<xunit_report_path> --coveragereportpath=<report_path>
//
// where `BROWSER` could be Chrome or Firefox.
//
// Karma config for xmodule suite.
// Docs and troubleshooting tips in common/static/common/js/karma.common.conf.js
/* jshint node: true */
/*jshint -W079 */
'use strict';
var path = require('path');
var _ = require('underscore');
var configModule = require(path.join(__dirname, 'common_static/common/js/karma.common.conf.js'));
var libraryFiles = [
// override fixture path and other config.
{pattern: path.join(configModule.appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true},
var options = {
{pattern: 'common_static/js/vendor/jquery.min.js', included: true},
{pattern: 'common_static/js/test/i18n.js', included: true},
{pattern: 'common_static/coffee/src/ajax_prefix.js', included: true},
{pattern: 'common_static/js/src/logger.js', included: true},
{pattern: 'common_static/js/vendor/jasmine-imagediff.js', included: true},
{pattern: 'common_static/js/libs/jasmine-waituntil.js', included: true},
{pattern: 'common_static/js/libs/jasmine-extensions.js', included: true},
{pattern: 'common_static/js/vendor/requirejs/require.js', included: true},
{pattern: 'RequireJS-namespace-undefine.js', included: true},
{pattern: 'common_static/js/vendor/jquery-ui.min.js', included: true},
{pattern: 'common_static/js/vendor/jquery.ui.draggable.js', included: true},
{pattern: 'common_static/js/vendor/jquery.cookie.js', included: true},
{pattern: 'common_static/js/vendor/json2.js', included: true},
{pattern: 'common_static/common/js/vendor/underscore.js', included: true},
{pattern: 'common_static/common/js/vendor/backbone.js', included: true},
{pattern: 'common_static/js/vendor/jquery.leanModal.js', included: true},
{pattern: 'common_static/js/vendor/CodeMirror/codemirror.js', included: true},
{pattern: 'common_static/js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js', included: true},
{pattern: 'common_static/js/vendor/tinymce/js/tinymce/tinymce.full.min.js', included: true},
{pattern: 'common_static/js/vendor/jquery.timeago.js', included: true},
{pattern: 'common_static/js/vendor/sinon-1.17.0.js', included: true},
{pattern: 'common_static/js/test/add_ajax_prefix.js', included: true},
{pattern: 'common_static/js/src/utility.js', included: true},
{pattern: 'public/js/split_test_staff.js', included: true},
{pattern: 'common_static/js/src/accessibility_tools.js', included: true},
{pattern: 'common_static/js/vendor/moment.min.js', included: true},
{pattern: 'spec/main_requirejs.js', included: true},
{pattern: 'src/word_cloud/d3.min.js', included: true},
{pattern: 'common_static/js/vendor/draggabilly.js', included: false},
{pattern: 'common_static/edx-ui-toolkit/js/utils/global-loader.js', included: true},
{pattern: 'common_static/edx-pattern-library/js/modernizr-custom.js', included: false},
{pattern: 'common_static/edx-pattern-library/js/afontgarde.js', included: false},
{pattern: 'common_static/edx-pattern-library/js/edx-icons.js', included: false}
];
useRequireJs: false,
// Paths to source JavaScript files
var sourceFiles = [
{pattern: 'src/xmodule.js', included: true, skipInstrument: true},
{pattern: 'src/**/*.js', included: true}
];
normalizePathsForCoverageFunc: function(appRoot, pattern) {
return pattern;
},
// Paths to spec (test) JavaScript files
var specFiles = [
{pattern: 'spec/helper.js', included: true, skipInstrument: true},
{pattern: 'spec/**/*.js', included: true}
];
// Avoid adding files to this list. Use RequireJS.
libraryFilesToInclude: [
{pattern: 'common_static/js/vendor/requirejs/require.js', included: true},
{pattern: 'RequireJS-namespace-undefine.js', included: true},
{pattern: 'spec/main_requirejs.js', included: true},
// Paths to fixture files
var fixtureFiles = [
{pattern: 'fixtures/*.*', included: false, served: true}
];
{pattern: 'common_static/coffee/src/ajax_prefix.js', included: true},
{pattern: 'common_static/common/js/vendor/underscore.js', included: true},
{pattern: 'common_static/common/js/vendor/backbone.js', included: true},
{pattern: 'common_static/edx-ui-toolkit/js/utils/global-loader.js', included: true},
{pattern: 'common_static/js/vendor/CodeMirror/codemirror.js', included: true},
{pattern: 'common_static/js/vendor/draggabilly.js'},
{pattern: 'common_static/js/vendor/jquery.min.js', included: true},
{pattern: 'common_static/js/vendor/jquery.cookie.js', included: true},
{pattern: 'common_static/js/vendor/jquery.leanModal.js', included: true},
{pattern: 'common_static/js/vendor/jquery.timeago.js', included: true},
{pattern: 'common_static/js/vendor/jquery-ui.min.js', included: true},
{pattern: 'common_static/js/vendor/jquery.ui.draggable.js', included: true},
{pattern: 'common_static/js/vendor/json2.js', included: true},
{pattern: 'common_static/js/vendor/moment.min.js', included: true},
{pattern: 'common_static/js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js', included: true},
{pattern: 'common_static/js/vendor/tinymce/js/tinymce/tinymce.full.min.js', included: true},
{pattern: 'common_static/js/src/accessibility_tools.js', included: true},
{pattern: 'common_static/js/src/logger.js', included: true},
{pattern: 'common_static/js/src/utility.js', included: true},
{pattern: 'common_static/js/test/add_ajax_prefix.js', included: true},
{pattern: 'common_static/js/test/i18n.js', included: true},
{pattern: 'public/js/split_test_staff.js', included: true},
{pattern: 'src/word_cloud/d3.min.js', included: true},
var runAndConfigFiles = [
{pattern: 'karma_runner.js', included: true}
];
{pattern: 'common_static/js/vendor/jasmine-imagediff.js', included: true},
{pattern: 'common_static/common/js/spec_helpers/jasmine-waituntil.js', included: true},
{pattern: 'common_static/common/js/spec_helpers/jasmine-extensions.js', included: true},
{pattern: 'common_static/js/vendor/sinon-1.17.0.js', included: true}
],
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = (function () {
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
libraryFiles: [
{pattern: 'common_static/edx-pattern-library/js/**/*.js'}
],
if (!file.skipInstrument) {
preprocessFiles[pattern] = ['coverage'];
}
});
// Make sure the patterns in sourceFiles and specFiles do not match the same file.
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
sourceFiles: [
{pattern: 'src/xmodule.js', included: true, ignoreCoverage: true}, // To prevent getting instrumented twice.
{pattern: 'src/**/*.js', included: true}
],
return preprocessFiles;
}());
specFiles: [
{pattern: 'spec/helper.js', included: true, ignoreCoverage: true}, // Helper which depends on source files.
{pattern: 'spec/**/*.js', included: true}
],
module.exports = function (config) {
var commonConfig = configModule.getConfig(config, false),
files = _.flatten([libraryFiles, sourceFiles, specFiles, fixtureFiles, runAndConfigFiles]),
localConfig;
// add nocache in files if coverage is not set
if (!config.coverage) {
files.forEach(function (f) {
if (_.isObject(f)) {
f.nocache = true;
}
});
}
fixtureFiles: [
{pattern: 'fixtures/*.*'}
],
localConfig = {
files: files,
preprocessors: preprocessors
};
runFiles: [
{pattern: 'karma_runner.js', included: true}
]
};
config.set(_.extend(commonConfig, localConfig));
module.exports = function (config) {
configModule.configure(config, options);
};
// Common configuration for Karma
// Common settings and helpers for setting up Karma config.
//
// To run all the tests in a suite and print results to the console:
//
// karma start <karma_config_for_suite_path>
// E.g. karma start lms/static/karma_lms.conf.js
//
//
// To run the tests for debugging: Debugging can be done in any browser
// but Chrome's developer console debugging experience is best.
//
// karma start <karma_config_for_suite_path> --browsers=BROWSER --single-run=false
//
//
// To run the tests with coverage and junit reports:
//
// karma start <karma_config_for_suite_path> --browsers=BROWSER
// --coverage --junitreportpath=<xunit_report_path> --coveragereportpath=<report_path>
//
// where `BROWSER` could be Chrome or Firefox.
//
//
// Troubleshooting tips:
//
// If you get an error like: "TypeError: __cov_KBCc7ZI4xZm8W2BC5NQLDg.s is undefined",
// that means the patterns in sourceFiles and specFiles are matching the same file.
// This causes Istanbul, which is used for tracking coverage to instrument the file
// multiple times.
//
//
// If you see the error: "EMFILE, too many open files" that means the files pattern
// that has been added is matching too many files. The glob library used by Karma
// does not use graceful-fs and tries to read files simultaneously.
//
/* jshint node: true */
/*jshint -W079 */
'use strict';
......@@ -7,6 +42,31 @@ var path = require('path');
var _ = require('underscore');
var appRoot = path.join(__dirname, '../../../../');
// Files which are needed by all lms/cms suites.
var commonFiles = {
libraryFiles: [
{pattern: 'common/js/vendor/**/*.js'},
{pattern: 'edx-pattern-library/js/**/*.js'},
{pattern: 'edx-ui-toolkit/js/**/*.js'},
{pattern: 'xmodule_js/common_static/coffee/src/**/!(*spec).js'},
{pattern: 'xmodule_js/common_static/js/**/!(*spec).js'},
{pattern: 'xmodule_js/src/**/*.js'}
],
sourceFiles: [
{pattern: 'common/js/components/**/*.js'},
{pattern: 'common/js/utils/**/*.js'}
],
specFiles: [
{pattern: 'common/js/spec_helpers/**/*.js'}
],
fixtureFiles: [
{pattern: 'common/templates/**/*.underscore'}
]
};
/**
* Customize the name attribute in xml testcase element
* @param {Object} browser
......@@ -102,27 +162,66 @@ function junitSettings(config) {
};
}
var getPreprocessorObject = function (files) {
var preprocessFiles = {};
/**
* Return absolute path for files in common and xmodule_js symlink dirs.
* @param {String} appRoot
* @param {String} pattern
* @return {String}
*/
var defaultNormalizeFunc = function (appRoot, pattern) {
if (pattern.match(/^common\/js/)) {
pattern = path.join(appRoot, '/common/static/' + pattern);
} else if (pattern.match(/^xmodule_js\/common_static/)) {
pattern = path.join(appRoot, '/common/static/' +
pattern.replace(/^xmodule_js\/common_static\//, ''));
}
return pattern;
};
files.forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
var normalizePathsForCoverage = function(files, normalizeFunc) {
var normalizeFn = normalizeFunc || defaultNormalizeFunc,
filesForCoverage = {};
if (pattern.match(/^common\/js/)) {
pattern = path.join(appRoot, '/common/static/' + pattern);
} else if (pattern.match(/^xmodule_js\/common_static/)) {
pattern = path.join(appRoot, '/common/static/' +
pattern.replace(/^xmodule_js\/common_static\//, ''));
files.forEach(function (file) {
if (!file.ignoreCoverage) {
filesForCoverage[normalizeFn(appRoot, file.pattern)] = ['coverage'];
}
});
return filesForCoverage;
};
preprocessFiles[pattern] = ['coverage'];
/**
* Sets nocache on each file in the list.
* @param {Object} files
* @param {Bool} enable
* @return {Object}
*/
var setNocache = function (files, enable) {
files.forEach(function (f) {
if (_.isObject(f)) {
f.nocache = enable;
}
});
return files;
};
return preprocessFiles;
/**
* Sets defaults for each file pattern.
* @param {Object} files
* @return {Object}
*/
var setDefaults = function (files) {
return files.map(function (f) {
var file = _.isObject(f) ? f : {pattern: f};
if (!file.included) {
f.included = false;
}
return file;
});
};
var getConfig = function (config, useRequireJs) {
useRequireJs = useRequireJs === undefined ? true : useRequireJs;
var getBaseConfig = function (config, useRequireJs) {
var getFrameworkFiles = function () {
var files = [
......@@ -235,8 +334,62 @@ var getConfig = function (config, useRequireJs) {
};
};
var configure = function(config, options) {
var useRequireJs = options.useRequireJs === undefined ? true : useRequireJs,
baseConfig = getBaseConfig(config, useRequireJs);
if (options.includeCommonFiles) {
_.forEach(['libraryFiles', 'sourceFiles', 'specFiles', 'fixtureFiles'], function (collectionName) {
options[collectionName] = _.flatten([commonFiles[collectionName], options[collectionName]]);
});
}
var files = _.flatten(
_.map(
['libraryFilesToInclude', 'libraryFiles', 'sourceFiles', 'specFiles', 'fixtureFiles', 'runFiles'],
function(collectionName) { return options[collectionName] || []; }
)
);
files.unshift(
{pattern: path.join(appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true}
);
if (useRequireJs) {
files.unshift({pattern: 'common/js/utils/require-serial.js', included: true});
}
// Karma sets included=true by default.
// We set it to false by default because RequireJS should be used instead.
files = setDefaults(files);
// With nocache=true, Karma always serves the latest files from disk.
// However, that prevents coverage tracking from working.
// So we only set it if coverage tracking is off.
setNocache(files, !config.coverage);
var filesForCoverage = _.flatten(
_.map(
['sourceFiles', 'specFiles'],
function(collectionName) { return options[collectionName]; }
)
);
// If we give symlink paths to Istanbul, coverage for each path gets tracked
// separately. So we pass absolute paths to the karma-coverage preprocessor.
var preprocessors = _.extend(
{},
options.preprocessors,
normalizePathsForCoverage(filesForCoverage, options.normalizePathsForCoverageFunc)
);
config.set(_.extend(baseConfig, {
files: files,
preprocessors: preprocessors
}));
};
module.exports = {
getConfig: getConfig,
getPreprocessorObject: getPreprocessorObject,
configure: configure,
appRoot: appRoot
};
......@@ -3,7 +3,7 @@
'use strict';
define(["jquery", "common/js/components/views/feedback", "common/js/components/views/feedback_notification",
"common/js/components/views/feedback_alert", "common/js/components/views/feedback_prompt",
'common/js/spec_helpers/view_helpers', "sinon", "jquery.simulate", "jasmine-waituntil"],
'common/js/spec_helpers/view_helpers', "sinon", "jquery.simulate"],
function($, SystemFeedback, NotificationView, AlertView, PromptView, ViewHelpers, sinon) {
var tpl;
tpl = readFixtures('common/templates/components/system-feedback.underscore');
......
;(function (define) {
'use strict';
define(["jquery", "underscore", "backbone", "common/js/components/utils/view_utils",
"common/js/spec_helpers/view_helpers", "jasmine-stealth"],
"common/js/spec_helpers/view_helpers"],
function ($, _, Backbone, ViewUtils, ViewHelpers) {
describe("ViewUtils", function() {
......
......@@ -34,10 +34,7 @@
'modernizr': 'edx-pattern-library/js/modernizr-custom',
'afontgarde': 'edx-pattern-library/js/afontgarde',
'edxicons': 'edx-pattern-library/js/edx-icons',
'draggabilly': 'js/vendor/draggabilly',
'jasmine-stealth': 'js/libs/jasmine-stealth',
'jasmine-waituntil': 'js/libs/jasmine-waituntil',
'jasmine-extensions': 'js/libs/jasmine-extensions'
'draggabilly': 'js/vendor/draggabilly'
},
shim: {
'gettext': {
......@@ -140,13 +137,13 @@
exports: 'URI'
},
'jasmine-imagediff': {},
'jasmine-stealth': {
deps: ['underscore', 'underscore.string']
},
'jasmine-waituntil': {
'common/js/spec_helpers/jasmine-extensions': {
deps: ['jquery']
},
'jasmine-extensions': {
'common/js/spec_helpers/jasmine-stealth': {
deps: ['underscore', 'underscore.string']
},
'common/js/spec_helpers/jasmine-waituntil': {
deps: ['jquery']
},
"sinon": {
......@@ -178,7 +175,15 @@
testFiles[i] = '/base/' + testFiles[i];
}
window.requireSerial(testFiles, function () {
var specHelpers = [
'common/js/spec_helpers/jasmine-extensions',
'common/js/spec_helpers/jasmine-stealth',
'common/js/spec_helpers/jasmine-waituntil'
];
// Jasmine has a global stack for creating a tree of specs. We need to load
// spec files one by one, otherwise some end up getting nested under others.
window.requireSerial(specHelpers.concat(testFiles), function () {
// start test run, once Require.js is done
window.__karma__.start();
});
......
---
# JavaScript test suite description
#
#
# To run all the tests and print results to the console:
#
# js-test-tool run TEST_SUITE --use-firefox
#
# where `TEST_SUITE` is this file.
#
#
# To run the tests in your default browser ("dev mode"):
#
# js-test-tool dev TEST_SUITE
#
test_suite_name: common
test_runner: jasmine
# Path prepended to source files in the coverage report (optional)
# For example, if the source path
# is "src/source.js" (relative to this YAML file)
# and the prepend path is "base/dir"
# then the coverage report will show
# "base/dir/src/source.js"
prepend_path: common/static
# Paths to library JavaScript files (optional)
lib_paths:
- js/vendor/jquery.min.js
- js/vendor/jasmine-imagediff.js
- js/libs/jasmine-waituntil.js
- js/vendor/jquery.truncate.js
- js/vendor/mustache.js
- common/js/vendor/underscore.js
- common/js/vendor/underscore.string.js
- common/js/vendor/backbone.js
- js/vendor/jquery.timeago.js
- js/vendor/URI.min.js
- js/vendor/draggabilly.js
- coffee/src/ajax_prefix.js
- js/test/add_ajax_prefix.js
- js/test/i18n.js
- coffee/src/jquery.immediateDescendents.js
- edx-pattern-library/js/modernizr-custom.js
- edx-pattern-library/js/afontgarde.js
- edx-pattern-library/js/edx-icons.js
# Paths to source JavaScript files
src_paths:
- js/xblock
- coffee/src
- js/src
- js/capa/src
# Paths to spec (test) JavaScript files
spec_paths:
- coffee/spec
- js/spec
- js/capa/spec
# Regular expressions used to exclude *.js files from
# appearing in the test runner page.
# Files are included by default, which means that they
# are loaded using a <script> tag in the test runner page.
# When loading many files, this can be slow, so
# exclude any files you don't need.
#exclude_from_page:
# - path/to/lib/include/exception_*.js
# Regular expression used to guarantee that a *.js file
# is included in the test runner page.
# If a file name matches both `exclude_from_page` and
# `include_in_page`, the file WILL be included.
# You can use this to exclude all files in a directory,
# but make an exception for particular files.
#include_in_page:
# - path/to/lib/exclude/exception_*.js
# Paths to fixture files (optional)
# You can access these within JavaScript code
# at the URL: document.location.href + "/include/"
# plus the path to the file (relative to this YAML file)
fixture_paths:
- js/fixtures
- js/capa/fixtures
- common/templates
---
# Common JavaScript tests, using RequireJS.
#
#
# To run all the tests and print results to the console:
#
# js-test-tool run TEST_SUITE --use-firefox
#
# where `TEST_SUITE` is this file.
#
#
# To run the tests in your default browser ("dev mode"):
#
# js-test-tool dev TEST_SUITE
#
test_suite_name: common-requirejs
test_runner: jasmine_requirejs
# Path prepended to source files in the coverage report (optional)
# For example, if the source path
# is "src/source.js" (relative to this YAML file)
# and the prepend path is "base/dir"
# then the coverage report will show
# "base/dir/src/source.js"
prepend_path: common/static
# Paths to library JavaScript files (optional)
lib_paths:
- js/vendor/jquery.min.js
- js/vendor/jasmine-imagediff.js
- js/libs/jasmine-stealth.js
- js/libs/jasmine-waituntil.js
- js/vendor/jquery.simulate.js
- js/vendor/jquery.truncate.js
- common/js/vendor/underscore.js
- common/js/vendor/underscore.string.js
- common/js/vendor/backbone.js
- js/vendor/backbone.paginator.min.js
- js/vendor/jquery.timeago.js
- js/vendor/URI.min.js
- coffee/src/ajax_prefix.js
- js/test/add_ajax_prefix.js
- js/test/i18n.js
- coffee/src/jquery.immediateDescendents.js
- js/vendor/requirejs/text.js
- js/vendor/sinon-1.17.0.js
# Paths to source JavaScript files
src_paths:
- common/js
- edx-pattern-library/js
- edx-ui-toolkit/js
# Paths to spec (test) JavaScript files
spec_paths:
- common/js/spec
# Paths to fixture files (optional)
# The fixture path will be set automatically when using jasmine-jquery.
# (https://github.com/velesin/jasmine-jquery)
#
# You can then access fixtures using paths relative to
# the test suite description:
#
# loadFixtures('path/to/fixture/fixture.html');
#
fixture_paths:
- common/templates
requirejs:
paths:
main: common/js/spec/main_requirejs
# Because require.js is responsible for loading all dependencies, we exclude
# all files from being included in <script> tags
exclude_from_page:
- .*
// Common JavaScript tests
//
// To run all the tests and print results to the console:
//
// karma start common/static/karma_common.conf.js
//
//
// To run the tests for debugging: Debugging can be done in any browser
// but Chrome's developer console debugging experience is best.
//
// karma start common/static/karma_common.conf.js --browsers=BROWSER --single-run=false
//
//
// To run the tests with coverage and junit reports:
//
// karma start common/static/karma_common.conf.js --browsers=BROWSER --coverage
// --junitreportpath=<xunit_report_path> --coveragereportpath=<report_path>
//
// where `BROWSER` could be Chrome or Firefox.
//
// Karma config for common suite.
// Docs and troubleshooting tips in common/static/common/js/karma.common.conf.js
/* jshint node: true */
/*jshint -W079 */
'use strict';
var path = require('path');
var _ = require('underscore');
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
// Files to load by Karma
var libraryFiles = [
// override fixture path and other config.
{pattern: path.join(configModule.appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true},
var options = {
{pattern: 'js/vendor/jquery.min.js', included: true},
{pattern: 'js/vendor/jasmine-imagediff.js', included: true},
{pattern: 'js/libs/jasmine-waituntil.js', included: true},
{pattern: 'js/libs/jasmine-extensions.js', included: true},
{pattern: 'js/vendor/jquery.truncate.js', included: true},
{pattern: 'js/vendor/mustache.js', included: true},
{pattern: 'common/js/vendor/underscore.js', included: true},
{pattern: 'common/js/vendor/underscore.string.js', included: true},
{pattern: 'common/js/vendor/backbone.js', included: true},
{pattern: 'js/vendor/jquery.timeago.js', included: true},
{pattern: 'js/vendor/URI.min.js', included: true},
{pattern: 'coffee/src/ajax_prefix.js', included: true},
{pattern: 'js/test/add_ajax_prefix.js', included: true},
{pattern: 'js/test/i18n.js', included: true},
{pattern: 'coffee/src/jquery.immediateDescendents.js', included: true},
{pattern: 'js/vendor/jquery.leanModal.js', included: true},
{pattern: 'js/vendor/draggabilly.js', included: true},
{pattern: 'edx-ui-toolkit/js/utils/global-loader.js', included: true},
{pattern: 'edx-pattern-library/js/modernizr-custom.js', included: true},
{pattern: 'edx-pattern-library/js/afontgarde.js', included: true},
{pattern: 'edx-pattern-library/js/edx-icons.js', included: true}
];
useRequireJs: false,
// Paths to source JavaScript files
var sourceFiles = [
{pattern: 'js/xblock/**/*.js', included: true},
{pattern: 'coffee/src/**/*.js', included: true},
{pattern: 'js/src/**/*.js', included: true},
{pattern: 'js/capa/src/**/*.js', included: true}
];
normalizePathsForCoverageFunc: function (appRoot, pattern) {
return path.join(appRoot, '/common/static/' + pattern);
},
// Paths to spec (test) JavaScript files
var specFiles = [
{pattern: 'coffee/spec/**/*.js', included: true},
{pattern: 'js/spec/**/*.js', included: true},
{pattern: 'js/capa/spec/**/*.js', included: true}
];
// Avoid adding files to this list. Use RequireJS.
libraryFilesToInclude: [
{pattern: 'coffee/src/ajax_prefix.js', included: true},
{pattern: 'js/vendor/draggabilly.js', included: true},
{pattern: 'js/vendor/jquery.min.js', included: true},
{pattern: 'coffee/src/jquery.immediateDescendents.js', included: true},
{pattern: 'js/vendor/jquery.leanModal.js', included: true},
{pattern: 'js/vendor/jquery.timeago.js', included: true},
{pattern: 'js/vendor/jquery.truncate.js', included: true},
{pattern: 'js/vendor/mustache.js', included: true},
{pattern: 'js/vendor/URI.min.js', included: true},
{pattern: 'js/test/add_ajax_prefix.js', included: true},
{pattern: 'js/test/i18n.js', included: true},
// Paths to fixture files
var fixtureFiles = [
{pattern: 'js/fixtures/**/*.html', included: false},
{pattern: 'js/capa/fixtures/**/*.html', included: false},
{pattern: 'common/templates/**/*.underscore', included: false}
];
{pattern: 'common/js/vendor/underscore.js', included: true},
{pattern: 'common/js/vendor/underscore.string.js', included: true},
{pattern: 'common/js/vendor/backbone.js', included: true},
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = (function () {
var preprocessFiles = {};
{pattern: 'edx-ui-toolkit/js/utils/global-loader.js', included: true},
{pattern: 'edx-pattern-library/js/modernizr-custom.js', included: true},
{pattern: 'edx-pattern-library/js/afontgarde.js', included: true},
{pattern: 'edx-pattern-library/js/edx-icons.js', included: true},
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
pattern = path.join(configModule.appRoot, '/common/static/' + pattern);
preprocessFiles[pattern] = ['coverage'];
});
{pattern: 'js/vendor/jasmine-imagediff.js', included: true},
{pattern: 'common/js/spec_helpers/jasmine-extensions.js', included: true},
{pattern: 'common/js/spec_helpers/jasmine-waituntil.js', included: true}
],
return preprocessFiles;
}());
libraryFiles: [
],
module.exports = function (config) {
var commonConfig = configModule.getConfig(config, false),
files = _.flatten([libraryFiles, sourceFiles, specFiles, fixtureFiles]),
localConfig;
// Make sure the patterns in sourceFiles and specFiles do not match the same file.
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
sourceFiles: [
{pattern: 'js/xblock/**/*.js', included: true},
{pattern: 'coffee/src/**/*.js', included: true},
{pattern: 'js/src/**/*.js', included: true},
{pattern: 'js/capa/src/**/*.js', included: true}
],
// add nocache in files if coverage is not set
if (!config.coverage) {
files.forEach(function (f) {
if (_.isObject(f)) {
f.nocache = true;
}
});
}
specFiles: [
{pattern: 'coffee/spec/**/*.js', included: true},
{pattern: 'js/spec/**/*.js', included: true},
{pattern: 'js/capa/spec/**/*.js', included: true}
],
localConfig = {
files: files,
preprocessors: preprocessors
};
fixtureFiles: [
{pattern: 'js/fixtures/**/*.html'},
{pattern: 'js/capa/fixtures/**/*.html'},
{pattern: 'common/templates/**/*.underscore'}
]
};
config.set(_.extend(commonConfig, localConfig));
module.exports = function (config) {
configModule.configure(config, options);
};
// Common JavaScript tests, using RequireJS.
//
// To run all the tests and print results to the console:
//
// karma start common/static/karma_common_requirejs.conf.js
//
//
// To run the tests for debugging: Debugging can be done in any browser
// but Chrome's developer console debugging experience is best.
//
// karma start karma_common_requirejs.conf.js --browsers=BROWSER --single-run=false
//
//
// To run the tests with coverage and junit reports:
//
// karma start karma_common_requirejs.conf.js --browsers=BROWSER --coverage
// --junitreportpath=<xunit_report_path> --coveragereportpath=<report_path>
//
// where `BROWSER` could be Chrome or Firefox.
//
// Karma config for common-requirejs suite.
// Docs and troubleshooting tips in common/static/common/js/karma.common.conf.js
/* jshint node: true */
/*jshint -W079 */
'use strict';
var path = require('path');
var _ = require('underscore');
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
var libraryFiles = [
{pattern: 'js/vendor/jquery.min.js', included: false},
{pattern: 'js/vendor/jasmine-imagediff.js', included: false},
{pattern: 'js/libs/jasmine-stealth.js', included: false},
{pattern: 'js/libs/jasmine-waituntil.js', included: false},
{pattern: 'js/libs/jasmine-extensions.js', included: false},
{pattern: 'js/vendor/jquery.simulate.js', included: false},
{pattern: 'js/vendor/jquery.truncate.js', included: false},
{pattern: 'common/js/vendor/underscore.js', included: false},
{pattern: 'common/js/vendor/underscore.string.js', included: false},
{pattern: 'common/js/vendor/backbone.js', included: false},
{pattern: 'js/vendor/backbone.paginator.min.js', included: false},
{pattern: 'js/vendor/jquery.timeago.js', included: false},
{pattern: 'js/vendor/URI.min.js', included: false},
{pattern: 'coffee/src/ajax_prefix.js', included: false},
{pattern: 'js/test/add_ajax_prefix.js', included: false},
{pattern: 'js/test/i18n.js', included: false},
{pattern: 'coffee/src/jquery.immediateDescendents.js', included: false},
{pattern: 'js/vendor/requirejs/text.js', included: false},
{pattern: 'js/vendor/sinon-1.17.0.js', included: false},
{pattern: 'common/js/utils/require-serial.js', included: true}
];
var options = {
// Paths to source JavaScript files
var sourceFiles = [
{pattern: 'common/js/**/!(*spec).js', included: false}
];
includeCommonFiles: true,
// Paths to spec (test) JavaScript files
var specFiles = [
{pattern: 'common/js/spec/**/*spec.js', included: false}
];
normalizePathsForCoverageFunc: function (appRoot, pattern) {
return path.join(appRoot, '/common/static/' + pattern);
},
// Paths to fixture files
var fixtureFiles = [
{pattern: 'common/templates/**/*.*', included: false}
];
libraryFiles: [
{pattern: 'coffee/src/**/*.js'},
{pattern: 'js/libs/**/*.js'},
{pattern: 'js/test/**/*.js'},
{pattern: 'js/vendor/**/*.js'}
],
// override fixture path and other config.
var runAndConfigFiles = [
{pattern: path.join(configModule.appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true},
'common/js/spec/main_requirejs.js'
];
// Make sure the patterns in sourceFiles and specFiles do not match the same file.
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
sourceFiles: [],
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = (function () {
var preprocessFiles = {};
specFiles: [
{pattern: 'common/js/spec/**/*spec.js'}
],
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
pattern = path.join(configModule.appRoot, '/common/static/' + pattern);
preprocessFiles[pattern] = ['coverage'];
});
fixtureFiles: [
{pattern: 'common/templates/**/*.*'}
],
return preprocessFiles;
}());
runFiles: [
{pattern: 'common/js/spec/main_requirejs.js', included: true}
]
};
module.exports = function (config) {
var commonConfig = configModule.getConfig(config),
files = _.flatten([libraryFiles, sourceFiles, specFiles, fixtureFiles, runAndConfigFiles]),
localConfig;
// add nocache in files if coverage is not set
if (!config.coverage) {
files.forEach(function (f) {
if (_.isObject(f)) {
f.nocache = true;
}
});
}
localConfig = {
files: files,
preprocessors: preprocessors
};
config.set(_.extend(commonConfig, localConfig));
configModule.configure(config, options);
};
......@@ -33,7 +33,7 @@
'text': 'xmodule_js/common_static/js/vendor/requirejs/text',
'underscore': 'common/js/vendor/underscore',
'underscore.string': 'common/js/vendor/underscore.string',
'backbone': 'xmodule_js/common_static/common/js/vendor/backbone',
'backbone': 'common/js/vendor/backbone',
'backbone.associations': 'xmodule_js/common_static/js/vendor/backbone-associations-min',
'backbone.paginator': 'xmodule_js/common_static/js/vendor/backbone.paginator.min',
'backbone-super': 'js/vendor/backbone-super',
......@@ -46,9 +46,6 @@
'sinon': 'xmodule_js/common_static/js/vendor/sinon-1.17.0',
'squire': 'xmodule_js/common_static/js/vendor/Squire',
'jasmine-imagediff': 'xmodule_js/common_static/js/vendor/jasmine-imagediff',
'jasmine-stealth': 'xmodule_js/common_static/js/vendor/jasmine-stealth',
'jasmine-waituntil': 'xmodule_js/common_static/js/libs/jasmine-waituntil',
'jasmine-extensions': 'xmodule_js/common_static/js/libs/jasmine-extensions',
'domReady': 'xmodule_js/common_static/js/vendor/domReady',
'mathjax': '//cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-MML-AM_SVG&delayStartupUntil=configured', // jshint ignore:line
'youtube': '//www.youtube.com/player_api?noext',
......@@ -69,9 +66,9 @@
'MathJaxProcessor': 'coffee/src/customwmd',
'picturefill': 'common/js/vendor/picturefill',
'draggabilly': 'xmodule_js/common_static/js/vendor/draggabilly',
'modernizr': 'xmodule_js/common_static/edx-pattern-library/js/modernizr-custom',
'afontgarde': 'xmodule_js/common_static/edx-pattern-library/js/afontgarde',
'edxicons': 'xmodule_js/common_static/edx-pattern-library/js/edx-icons',
'modernizr': 'edx-pattern-library/js/modernizr-custom',
'afontgarde': 'edx-pattern-library/js/afontgarde',
'edxicons': 'edx-pattern-library/js/edx-icons',
// Manually specify LMS files that are not converted to RequireJS
'history': 'js/vendor/history',
......@@ -104,7 +101,7 @@
'annotator_1.2.9': 'xmodule_js/common_static/js/vendor/edxnotes/annotator-full.min',
// Common edx utils
'common/js/utils/edx.utils.validate': 'xmodule_js/common_static/common/js/utils/edx.utils.validate',
'common/js/utils/edx.utils.validate': 'common/js/utils/edx.utils.validate',
'slick.core': 'xmodule_js/common_static/js/vendor/slick.core',
'slick.grid': 'xmodule_js/common_static/js/vendor/slick.grid'
},
......@@ -260,13 +257,13 @@
exports: 'sinon'
},
'jasmine-imagediff': {},
'jasmine-stealth': {
deps: ['underscore', 'underscore.string']
},
'jasmine-waituntil': {
'common/js/spec_helpers/jasmine-extensions': {
deps: ['jquery']
},
'jasmine-extensions': {
'common/js/spec_helpers/jasmine-stealth': {
deps: ['underscore', 'underscore.string']
},
'common/js/spec_helpers/jasmine-waituntil': {
deps: ['jquery']
},
'xblock/core': {
......@@ -777,11 +774,16 @@
testFiles[i] = '/base/' + testFiles[i];
}
var specHelpers = [
'common/js/spec_helpers/jasmine-extensions',
'common/js/spec_helpers/jasmine-stealth',
'common/js/spec_helpers/jasmine-waituntil'
];
// Jasmine has a global stack for creating a tree of specs. We need to load
// spec files one by one, otherwise some end up getting nested under others.
window.requireSerial(testFiles, function () {
window.requireSerial(specHelpers.concat(testFiles), function () {
// start test run, once Require.js is done
window.__karma__.start();
});
}).call(this, requirejs, define);
......@@ -4,9 +4,9 @@
baseUrl: '/base/',
paths: {
"moment": "xmodule_js/common_static/js/vendor/moment.min",
"modernizr": "xmodule_js/common_static/edx-pattern-library/js/modernizr-custom",
"afontgarde": "xmodule_js/common_static/edx-pattern-library/js/afontgarde",
"edxicons": "xmodule_js/common_static/edx-pattern-library/js/edx-icons",
"modernizr": "edx-pattern-library/js/modernizr-custom",
"afontgarde": "edx-pattern-library/js/afontgarde",
"edxicons": "edx-pattern-library/js/edx-icons",
"draggabilly": "xmodule_js/common_static/js/vendor/draggabilly"
},
"moment": {
......
---
# LMS JavaScript tests (using RequireJS).
#
#
# To run all the tests and print results to the console:
#
# js-test-tool run TEST_SUITE --use-firefox
#
# where `TEST_SUITE` is this file.
#
#
# To run the tests in your default browser ("dev mode"):
#
# js-test-tool dev TEST_SUITE
#
test_suite_name: lms
test_runner: jasmine_requirejs
# Path prepended to source files in the coverage report (optional)
# For example, if the source path
# is "src/source.js" (relative to this YAML file)
# and the prepend path is "base/dir"
# then the coverage report will show
# "base/dir/src/source.js"
prepend_path: lms/static
# Paths to library JavaScript files (optional)
lib_paths:
- xmodule_js/common_static/js/test/i18n.js
- xmodule_js/common_static/coffee/src/ajax_prefix.js
- xmodule_js/common_static/js/src/logger.js
- xmodule_js/common_static/js/vendor/jasmine-imagediff.js
- xmodule_js/common_static/js/vendor/requirejs/require.js
- js/RequireJS-namespace-undefine.js
- xmodule_js/common_static/js/vendor/requirejs/text.js
- xmodule_js/common_static/js/vendor/jquery.min.js
- xmodule_js/common_static/js/vendor/jquery-ui.min.js
- xmodule_js/common_static/js/vendor/jquery.simulate.js
- xmodule_js/common_static/js/vendor/jquery.cookie.js
- xmodule_js/common_static/js/vendor/jquery.timeago.js
- xmodule_js/common_static/js/vendor/flot/jquery.flot.js
- xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js
- xmodule_js/common_static/js/vendor/URI.min.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.iframe-transport.js
- xmodule_js/common_static/js/vendor/url.min.js
- xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js
- xmodule_js/common_static/js/xblock
- xmodule_js/common_static/coffee/src/xblock
- coffee/src/instructor_dashboard
- xmodule_js/common_static/js/vendor/sinon-1.17.0.js
- xmodule_js/src/capa/
- xmodule_js/src/video/
- xmodule_js/src/xmodule.js
- xmodule_js/common_static/js/src/
- xmodule_js/common_static/common/js/vendor/underscore.js
- xmodule_js/common_static/common/js/vendor/underscore.string.js
- xmodule_js/common_static/common/js/vendor/backbone.js
- xmodule_js/common_static/js/vendor/backbone.paginator.min.js
- xmodule_js/common_static/js/vendor/edxnotes/annotator-full.min.js
- xmodule_js/common_static/js/test/i18n.js
- xmodule_js/common_static/js/vendor/date.js
- xmodule_js/common_static/js/vendor/moment.min.js
- xmodule_js/common_static/js/vendor/moment-with-locales.min.js
- xmodule_js/common_static/common/js/utils/edx.utils.validate.js
- xmodule_js/common_static/js/vendor/slick.core.js
- xmodule_js/common_static/js/vendor/slick.grid.js
- xmodule_js/common_static/js/vendor/jquery.event.drag-2.2.js
- xmodule_js/common_static/common/js/vendor/picturefill.js
# Paths to source JavaScript files
src_paths:
- js
- coffee/src
- common/js
- edx-pattern-library/js
- edx-ui-toolkit/js
- support/js
- teams/js
- xmodule_js/common_static/coffee
# Paths to spec (test) JavaScript files
spec_paths:
- js/spec
- teams/js/spec
- support/js/spec
# Paths to fixture files (optional)
# The fixture path will be set automatically when using jasmine-jquery.
# (https://github.com/velesin/jasmine-jquery)
#
# You can then access fixtures using paths relative to
# the test suite description:
#
# loadFixtures('path/to/fixture/fixture.html');
#
fixture_paths:
- js/fixtures
- templates/instructor/instructor_dashboard_2
- templates/dashboard
- templates/edxnotes
- templates/fields
- templates/student_account
- templates/student_profile
- templates/verify_student
- templates/file-upload.underscore
- templates/components/header
- templates/components/card
- templates/financial-assistance/
- js/fixtures/edxnotes
- js/fixtures/search
- templates/search
- templates/discovery
- common/templates
- teams/templates
- support/templates
- js/fixtures/bookmarks
- templates/bookmarks
- templates/learner_dashboard
requirejs:
paths:
main: js/spec/main
# Because require.js is responsible for loading all dependencies, we exclude
# all files from being included in <script> tags
exclude_from_page:
- .*
---
# LMS CoffeeScript tests that are not yet using RequireJS.
#
#
# To run all the tests and print results to the console:
#
# js-test-tool run TEST_SUITE --use-firefox
#
# where `TEST_SUITE` is this file.
#
#
# To run the tests in your default browser ("dev mode"):
#
# js-test-tool dev TEST_SUITE
#
test_suite_name: lms-coffee
test_runner: jasmine
# Path prepended to source files in the coverage report (optional)
# For example, if the source path
# is "src/source.js" (relative to this YAML file)
# and the prepend path is "base/dir"
# then the coverage report will show
# "base/dir/src/source.js"
prepend_path: lms/static
# Paths to library JavaScript files (optional)
lib_paths:
- xmodule_js/common_static/js/test/i18n.js
- xmodule_js/common_static/coffee/src/ajax_prefix.js
- xmodule_js/common_static/js/src/logger.js
- xmodule_js/common_static/js/vendor/underscore-min.js
- xmodule_js/common_static/js/vendor/jasmine-imagediff.js
- xmodule_js/common_static/js/vendor/requirejs/require.js
- js/RequireJS-namespace-undefine.js
- xmodule_js/common_static/js/vendor/jquery-ui.min.js
- xmodule_js/common_static/js/vendor/jquery.cookie.js
- xmodule_js/common_static/js/vendor/flot/jquery.flot.js
- xmodule_js/common_static/js/vendor/moment.min.js
- xmodule_js/common_static/js/vendor/moment-with-locales.min.js
- xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js
- xmodule_js/common_static/js/vendor/URI.min.js
- xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js
- xmodule_js/common_static/js/xblock
- xmodule_js/common_static/coffee/src/xblock
- moment_requirejs.js
- xmodule_js/src/capa/
- xmodule_js/src/video/
- xmodule_js/src/xmodule.js
# Paths to source JavaScript files
src_paths:
- coffee/src
# Paths to spec (test) JavaScript files
spec_paths:
- coffee/spec
# Paths to fixture files (optional)
# The fixture path will be set automatically when using jasmine-jquery.
# (https://github.com/velesin/jasmine-jquery)
#
# You can then access fixtures using paths relative to
# the test suite description:
#
# loadFixtures('path/to/fixture/fixture.html');
#
fixture_paths:
- coffee/fixtures
# Regular expressions used to exclude *.js files from
# appearing in the test runner page.
# Files are included by default, which means that they
# are loaded using a <script> tag in the test runner page.
# When loading many files, this can be slow, so
# exclude any files you don't need.
#exclude_from_page:
# - coffee/spec/helper.js
# Regular expression used to guarantee that a *.js file
# is included in the test runner page.
# If a file name matches both `exclude_from_page` and
# `include_in_page`, the file WILL be included.
# You can use this to exclude all files in a directory,
# but make an exception for particular files.
#include_in_page:
# - path/to/lib/include/*
// LMS JavaScript tests, using RequireJS.
//
// To run all the tests and print results to the console:
//
// karma start lms/static/karma_lms.conf.js
//
//
// To run the tests for debugging: Debugging can be done in any browser but
// Chrome's developer console debugging experience is best.
//
// karma start lms/static/karma_lms.conf.js --browsers=BROWSER --single-run=false
//
//
// To run the tests with coverage and junit reports:
//
// karma start lms/static/karma_lms.conf.js --browsers=BROWSER
// --coverage --junitreportpath=<xunit_report_path> --coveragereportpath=<report_path>
//
// where `BROWSER` could be Chrome or Firefox.
//
// Karma config for lms suite.
// Docs and troubleshooting tips in common/static/common/js/karma.common.conf.js
/* jshint node: true */
/*jshint -W079 */
'use strict';
var path = require('path');
var _ = require('underscore');
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
var libraryFiles = [
{pattern: 'xmodule_js/common_static/js/test/i18n.js', included: false},
{pattern: 'xmodule_js/common_static/coffee/src/ajax_prefix.js', included: false},
{pattern: 'xmodule_js/common_static/js/src/logger.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/require.js', included: false},
{pattern: 'js/RequireJS-namespace-undefine.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/text.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jquery-ui.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.simulate.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.cookie.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.timeago.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/flot/jquery.flot.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/URI.min.js', included: false},
{
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload.js',
included: false
},
{
pattern: 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.iframe-transport.js',
included: false
},
{pattern: 'xmodule_js/common_static/js/vendor/url.min.js', included: false},
{pattern: 'xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js', included: false},
{pattern: 'xmodule_js/common_static/js/xblock/**/*.js', included: false},
{pattern: 'xmodule_js/common_static/coffee/src/xblock/**/*.js', included: false},
{pattern: 'coffee/src/instructor_dashboard/**/*.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/sinon-1.17.0.js', included: false},
{pattern: 'xmodule_js/src/capa/**/*.js', included: false},
{pattern: 'xmodule_js/src/video/**/*.js', included: false},
{pattern: 'xmodule_js/src/xmodule.js', included: false},
{pattern: 'xmodule_js/common_static/js/src/**/*.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.string.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/vendor/backbone.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/backbone.paginator.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/edxnotes/annotator-full.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/test/i18n.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/date.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/moment.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/moment-with-locales.min.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/utils/edx.utils.validate.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.event.drag-2.2.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/slick.core.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/slick.grid.js', included: true},
{pattern: 'xmodule_js/common_static/js/libs/jasmine-waituntil.js', included: true},
{pattern: 'xmodule_js/common_static/js/libs/jasmine-extensions.js', included: true},
{pattern: 'common/js/utils/require-serial.js', included: true}
];
// Paths to source JavaScript files
var sourceFiles = [
{pattern: 'js/**/!(*spec).js', included: false},
{pattern: 'coffee/src/**/*.js', included: false},
{pattern: 'common/js/**/*.js', included: false},
{pattern: 'edx-pattern-library/js/**/*.js', included: false},
{pattern: 'edx-ui-toolkit/js/**/*.js', included: false},
{pattern: 'support/js/**/!(*spec).js', included: false},
{pattern: 'teams/js/**/!(*spec).js', included: false},
{pattern: 'xmodule_js/common_static/coffee/**/*.js', included: false}
];
// Paths to spec (test) JavaScript files
var specFiles = [
{pattern: 'js/spec/**/*spec.js', included: false},
{pattern: 'teams/js/spec/**/*spec.js', included: false},
{pattern: 'support/js/spec/**/*spec.js', included: false}
];
// Paths to fixture files
var fixtureFiles = [
{pattern: 'js/fixtures/**/*.html', included: false},
{pattern: 'templates/instructor/instructor_dashboard_2/**/*.*', included: false},
{pattern: 'templates/dashboard/**/*.*', included: false},
{pattern: 'templates/edxnotes/**/*.*', included: false},
{pattern: 'templates/fields/**/*.*', included: false},
{pattern: 'templates/student_account/**/*.*', included: false},
{pattern: 'templates/student_profile/**/*.*', included: false},
{pattern: 'templates/verify_student/**/*.*', included: false},
{pattern: 'templates/file-upload.underscore', included: false},
{pattern: 'templates/components/header/**/*.*', included: false},
{pattern: 'templates/components/tabbed/**/*.*', included: false},
{pattern: 'templates/components/card/**/*.*', included: false},
{pattern: 'templates/financial-assistance/**/*.*', included: false},
{pattern: 'templates/search/**/*.*', included: false},
{pattern: 'templates/discovery/**/*.*', included: false},
{pattern: 'common/templates/**/*.*', included: false},
{pattern: 'teams/templates/**/*.*', included: false},
{pattern: 'support/templates/**/*.*', included: false},
{pattern: 'templates/bookmarks/**/*.*', included: false},
{pattern: 'templates/learner_dashboard/**/*.*', included: false},
{pattern: 'templates/ccx/**/*.*', included: false},
{pattern: 'templates/commerce/receipt.underscore', included: false},
{pattern: 'templates/api_admin/**/*.*', included: false}
];
// override fixture path and other config.
var runAndConfigFiles = [
{pattern: path.join(configModule.appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true},
{pattern: 'js/spec/main.js', included: true}
];
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
var options = {
includeCommonFiles: true,
// Avoid adding files to this list. Use RequireJS.
libraryFilesToInclude: [
{pattern: 'xmodule_js/common_static/js/vendor/jquery.event.drag-2.2.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/slick.core.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/slick.grid.js', included: true}
],
libraryFiles: [
{pattern: 'js/RequireJS-namespace-undefine.js'}
],
// Make sure the patterns in sourceFiles and specFiles do not match the same file.
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
sourceFiles: [
{pattern: 'coffee/src/**/!(*spec).js'},
{pattern: 'js/**/!(*spec|djangojs).js'},
{pattern: 'support/js/**/!(*spec).js'},
{pattern: 'teams/js/**/!(*spec).js'}
],
specFiles: [
{pattern: 'js/spec/**/*spec.js'},
{pattern: 'support/js/spec/**/*spec.js'},
{pattern: 'teams/js/spec/**/*spec.js'},
{pattern: 'xmodule_js/common_static/coffee/spec/**/*.js'}
],
fixtureFiles: [
{pattern: 'js/fixtures/**/*.html'},
{pattern: 'support/templates/**/*.*'},
{pattern: 'teams/templates/**/*.*'},
{pattern: 'templates/**/*.*'}
],
runFiles: [
{pattern: 'js/spec/main.js', included: true}
]
};
module.exports = function (config) {
var commonConfig = configModule.getConfig(config),
files = _.flatten([libraryFiles, sourceFiles, specFiles, fixtureFiles, runAndConfigFiles]),
localConfig;
// add nocache in files if coverage is not set
if (!config.coverage) {
files.forEach(function (f) {
if (_.isObject(f)) {
f.nocache = true;
}
});
}
localConfig = {
files: files,
preprocessors: preprocessors
};
config.set(_.extend(commonConfig, localConfig));
configModule.configure(config, options);
};
// LMS Coffee Script Tests.
//
// To run all the tests and print results to the console:
//
// karma start lms/static/karma_lms_coffee.conf.js
//
//
// To run the tests for debugging: Debugging can be done in any browser
// but Chrome's developer console debugging experience is best.
//
// karma start lms/static/karma_lms_coffee.conf.js --browsers=BROWSER --single-run=false
//
//
// To run the tests with coverage and junit reports:
//
// karma start lms/static/karma_lms_coffee.conf.js --browsers=BROWSER
// --coverage --junitreportpath=<xunit_report_path> --coveragereportpath=<report_path>
//
// where `BROWSER` could be Chrome or Firefox.
//
// Karma config for lms-coffee suite.
// Docs and troubleshooting tips in common/static/common/js/karma.common.conf.js
/* jshint node: true */
/*jshint -W079 */
'use strict';
var path = require('path');
var _ = require('underscore');
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
var libraryFiles = [
// override fixture path and other config.
{pattern: path.join(configModule.appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true},
var options = {
// vendor files
{pattern: 'xmodule_js/common_static/js/vendor/jquery.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/test/i18n.js', included: true},
{pattern: 'xmodule_js/common_static/coffee/src/ajax_prefix.js', included: true},
{pattern: 'xmodule_js/common_static/js/src/logger.js', included: true},
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jasmine-imagediff.js', included: true},
{pattern: 'xmodule_js/common_static/js/libs/jasmine-extensions.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/require.js', included: true},
{pattern: 'js/spec/main_requirejs_coffee.js', included: true},
{pattern: 'js/RequireJS-namespace-undefine.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jquery-ui.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.cookie.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/flot/jquery.flot.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/moment.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/moment-with-locales.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/URI.min.js', included: true},
{pattern: 'xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js', included: true},
{pattern: 'xmodule_js/common_static/js/xblock/*.js', included: true},
{pattern: 'xmodule_js/common_static/coffee/src/xblock/*.js', included: true},
{pattern: 'moment_requirejs.js', included: true},
{pattern: 'xmodule_js/src/capa/*.js', included: true},
{pattern: 'xmodule_js/src/video/*.js', included: true},
{pattern: 'xmodule_js/src/xmodule.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/draggabilly.js', included: false},
{pattern: 'xmodule_js/common_static/edx-ui-toolkit/js/utils/global-loader.js', included: true},
{pattern: 'xmodule_js/common_static/edx-pattern-library/js/modernizr-custom.js', included: false},
{pattern: 'xmodule_js/common_static/edx-pattern-library/js/afontgarde.js', included: false},
{pattern: 'xmodule_js/common_static/edx-pattern-library/js/edx-icons.js', included: false}
];
useRequireJs: false,
includeCommonFiles: true,
// source files
var sourceFiles = [
{pattern: 'coffee/src/**/*.js', included: true}
];
// Avoid adding files to this list. Use RequireJS.
libraryFilesToInclude: [
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/require.js', included: true},
{pattern: 'js/spec/main_requirejs_coffee.js', included: true},
// spec files
var specFiles = [
{pattern: 'coffee/spec/**/*.js', included: true}
];
{pattern: 'js/RequireJS-namespace-undefine.js', included: true},
{pattern: 'xmodule_js/common_static/coffee/src/ajax_prefix.js', included: true},
{pattern: 'common/js/vendor/underscore.js', included: true},
{pattern: 'edx-ui-toolkit/js/utils/global-loader.js', included: true},
{pattern: 'xmodule_js/common_static/js/src/logger.js', included: true},
{pattern: 'xmodule_js/common_static/js/test/i18n.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.cookie.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/flot/jquery.flot.js', included: true},
{pattern: 'xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jquery-ui.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/moment.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/moment-with-locales.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/URI.min.js', included: true},
// Fixtures
var fixtureFiles = [
{pattern: 'coffee/fixtures/**/*.*', included: true}
];
{pattern: 'xmodule_js/common_static/js/xblock/*.js', included: true},
{pattern: 'xmodule_js/common_static/coffee/src/xblock/*.js', included: true},
{pattern: 'xmodule_js/src/capa/*.js', included: true},
{pattern: 'xmodule_js/src/video/*.js', included: true},
{pattern: 'xmodule_js/src/xmodule.js', included: true},
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
{pattern: 'xmodule_js/common_static/js/vendor/jasmine-imagediff.js', included: true},
{pattern: 'common/js/spec_helpers/jasmine-extensions.js', included: true}
],
module.exports = function (config) {
var commonConfig = configModule.getConfig(config, false),
files = _.flatten([libraryFiles, sourceFiles, specFiles, fixtureFiles]),
localConfig;
libraryFiles: [
{pattern: 'xmodule_js/common_static/js/vendor/**/*.js'}
],
// Make sure the patterns in sourceFiles and specFiles do not match the same file.
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
sourceFiles: [
{pattern: 'coffee/src/**/*.js', included: true}
],
// add nocache in files if coverage is not set
if (!config.coverage) {
files.forEach(function (f) {
if (_.isObject(f)) {
f.nocache = true;
}
});
}
specFiles: [
{pattern: 'coffee/spec/**/*.js', included: true}
],
localConfig = {
files: files,
preprocessors: preprocessors
};
fixtureFiles: [
{pattern: 'coffee/fixtures/**/*.*', included: true}
]
};
config.set(_.extend(commonConfig, localConfig));
module.exports = function (config) {
configModule.configure(config, options);
};
(function(requirejs) {
'use strict';
requirejs.config({
paths: {
"moment": "/base/xmodule_js/common_static/js/vendor/moment.min"
},
shim:{
"moment": {
exports: "moment"
}
}
});
}).call(this, RequireJS.requirejs);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment