You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am facing below issue while running mocha test via karma
Uncaught Error: Mismatched anonymous define() module: function (workflow) {
var expect = chai.expect;
describe('Empty Workflow Project Creation Module Testing', function () {
it('should throw an error if project is not empty', function () {
var result = [];
alert('check des');
result=workflow.onAfterGenerate("projectzip", "model");
// result = onAfterGenerate("projectzip", "model");
expect(result[0]).to.equal("projectzip");
expect(result[1]).to.equal("model");
});
// if invoked in karma-runner environment
if (typeof window != 'undefined' && window.karma != undefined) {
// Karma serves files from '/base'
baseUrl = '/base';
requirejsCallback = window.karma.start;
// looking for *_spec.js files
specFiles = [];
for (var file in window.__karma__.files) {
if (window.__karma__.files.hasOwnProperty(file)) {
if (/.*\/js\/spec\/.+_spec\.js$/.test(file)) {
specFiles.push(file);
}
}
}
}
/** requirejs.config({
baseUrl: baseUrl,
paths: {
'chai': 'node_modules/chai/chai',
'sinon': 'node_modules/sinon/pkg/sinon'
},
// ask Require.js to load these files (all our tests)
deps: specFiles,
// start test run, once Require.js is done
callback: requirejsCallback
debugger;
alert('hello');
define(['../../src/workflow-tools/client/sap.bpm.webide.wfs.template.plugin/workflow/workflow'], function(workflow) {
var expect = chai.expect;
describe('Empty Workflow Project Creation Module Testing', function () {
it('should throw an error if project is not empty', function () {
var result = [];
alert('check des');
result=workflow.onAfterGenerate("projectzip", "model");
// result = onAfterGenerate("projectzip", "model");
expect(result[0]).to.equal("projectzip");
expect(result[1]).to.equal("model");
});
});
});
Thanks for help in advance
The text was updated successfully, but these errors were encountered:
I am facing below issue while running mocha test via karma
Uncaught Error: Mismatched anonymous define() module: function (workflow) {
describe('Empty Workflow Project Creation Module Testing', function () {
it('should throw an error if project is not empty', function () {
var result = [];
alert('check des');
});
}
http://requirejs.org/docs/errors.html#mismatch
at node_modules/requirejs/require.js:143
My karma conf file is :
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['requirejs','mocha','openui5'],
openui5: {
//path: 'https://sapui5.hana.ondemand.com/resources/sap-ui-core.js',
path: 'https://sapui5.hana.ondemand.com/1.30.8/resources/sap-ui-core.js',
useMockServer: false
},
files: [
{pattern: 'node_modules/**/*.js', included: false},
'test/test-main.js',
'js/spec/CreateEmptyWFProject_spec.js'
};
package.json looks like this
{
"name": "requirejs_mocha",
"version": "1.0.0",
"description": "check requirejs mocha karma",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.1.1",
"karma-mocha": "^1.3.0",
"karma-requirejs": "^1.1.0",
"requirejs": "^2.3.3"
}
}
Project structure :
test-main.js is
/**
*/
(function() {
debugger;
var specFiles = null;
var baseUrl = '';
var requirejsCallback = null;
// if invoked in karma-runner environment
if (typeof window != 'undefined' && window.karma != undefined) {
// Karma serves files from '/base'
baseUrl = '/base';
requirejsCallback = window.karma.start;
}
/** requirejs.config({
baseUrl: baseUrl,
}); **/
requirejs.config({
baseUrl: '/base',
deps: specFiles,
callback: mocha.run
});
})();
Test file : CreateEmptyWFProject_spec
debugger;
alert('hello');
define(['../../src/workflow-tools/client/sap.bpm.webide.wfs.template.plugin/workflow/workflow'], function(workflow) {
var expect = chai.expect;
describe('Empty Workflow Project Creation Module Testing', function () {
it('should throw an error if project is not empty', function () {
var result = [];
alert('check des');
});
});
Thanks for help in advance
The text was updated successfully, but these errors were encountered: