Commit fe0ea18b authored by Dorchies David's avatar Dorchies David
Browse files

#84 Allows karma (es2015 modules) AND jasmine tests. Build prod in es2015 module also.

parent e94a3e32
#!/bin/bash
do_kill()
{
local pid=$1
if [[ -n $pid ]]; then
if [[ -n $(ps -ef|grep $pid|grep -v grep) ]]; then
echo "killing $pid..."
kill $jm_pid
else
echo "no process with pid $pid"
fi
fi
}
do_exit()
{
# echo "exits"
do_kill $jm_pid
}
syntax()
{
echo "syntaxe : $(basename $0) <fichier spec>"
exit 1
}
trap do_exit SIGINT
trap do_exit EXIT
if [[ $# != 1 ]]; then
syntax
fi
ni=$(ps -ef|grep node-inspector|grep -v grep)
if [[ -z $ni ]]; then
echo "starting node-inspector..."
node-inspector &
else
echo "node-inspector already running"
fi
echo
echo "debugging $1..."
node --debug-brk ./node_modules/jasmine-node/bin/jasmine-node $1 &
jm_pid=$!
echo
#ps -ef|grep jasmine-node|grep -v grep
#pid=$(ps -ef|grep jasmine-node|grep -v grep|awk '{print $2}')
#echo $pid $jm_pid
echo "starting Chrome...."
chromium-browser http://127.0.0.1:8080/?port=5858
......@@ -10,15 +10,13 @@ module.exports = function (config) {
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'requirejs'],
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
{ pattern: 'spec/test-main.js', included: true },
{ pattern: 'spec/**/*.ts', included: false },
{ pattern: 'src/**/*.ts', included: false }
// { pattern: 'build/**/*.js', included: false }
{ pattern: 'build/spec/**/*.js', included: true, type: 'module' },
{ pattern: 'build/src/**/*.js', included: false, type: 'module' },
],
......@@ -30,29 +28,12 @@ module.exports = function (config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
// '+(src|spec)/**/*.ts': ['typescript']
'**/*.ts': ['typescript']
},
typescriptPreprocessor: {
// options passed to the typescript compiler
options: {
sourceMap: true, // (optional) Generates corresponding .map file.
// enum ScriptTarget { ES3 = 0, ES5 = 1, ES6 = 2, ES2015 = 2, Latest = 2 }
target: 'ES5', // (optional) Specify ECMAScript target version: 'ES3' (default), or 'ES5'
// enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, UMD = 3, System = 4, ES6 = 5, ES2015 = 5 }
module: 'amd', // (optional) Specify module code generation: 'commonjs' or 'amd'
// noImplicitAny: true, // (optional) Warn on expressions and declarations with an implied 'any' type.
// noResolve: true, // (optional) Skip resolution and preprocessing.
// removeComments: true, // (optional) Do not emit comments to output.
// concatenateOutput: false // (optional) Concatenate and emit output to single file. By default true if module option is omited, otherwise false.
},
// transforming the filenames
transformPath: function (path) {
return path.replace(/\.ts$/, '.js');
client: {
// Jasmine configuration, see https://github.com/karma-runner/karma-jasmine#configuration
jasmine: {
random: false
}
},
......@@ -72,8 +53,8 @@ module.exports = function (config) {
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// logLevel: config.LOG_DEBUG,
// logLevel: config.LOG_INFO,
logLevel: config.LOG_DEBUG,
// enable / disable watching file and executing tests whenever any file changes
......@@ -84,6 +65,13 @@ module.exports = function (config) {
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
plugins: [
'karma-jasmine',
'karma-chrome-launcher',
// 'karma-typescript',
'karma-jasmine-html-reporter',
// 'karma-browserify'
],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
......
This diff is collapsed.
......@@ -11,27 +11,31 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"module": "build/index.js",
"dependencies": {
"buffer": "^5.2.1"
},
"dependencies": {},
"devDependencies": {
"@types/jasmine": "2.8.8",
"@types/node": "10.5.2",
"jasmine": "3.1.0",
"jasmine-core": "3.1.0",
"buffer": "^5.2.1",
"jasmine": "3.4.0",
"jasmine-core": "3.4.0",
"jasmine-node": "1.15.0",
"karma": "^4.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"requirejs": "^2.3.6",
"tslint": "5.11.0",
"typescript": "2.9.2"
},
"scripts": {
"build": "npm run preprocess; ./node_modules/typescript/bin/tsc --p src/tsconfig.app.json",
"buildspec": "npm run preprocess; rm -rf build; ./node_modules/typescript/bin/tsc --p spec/tsconfig.spec.json",
"build": "npm run buildgeneric -- src/tsconfig.app.json",
"buildgeneric": "npm run preprocess; rm -rf build; ./node_modules/typescript/bin/tsc --p",
"runtestremous": "./node_modules/typescript/bin/tsc --p spec/tsconfig-remous-fenetre.spec.json && node ./build/spec/test-remous-fenetre.js",
"jasmine": "npm run buildspec && ./node_modules/.bin/jasmine",
"karma": "npm run preprocess; ./node_modules/typescript/bin/tsc --p spec/tsconfig.spec.json && ./node_modules/karma/bin/karma start",
"jasmine": "npm run buildgeneric -- spec/tsconfig.spec.jasmine.json && ./node_modules/.bin/jasmine",
"karma": "npm run buildgeneric -- spec/tsconfig.spec.karma.json && find ./build -type f -iname \"*.js\" -print0 | xargs -0 sed -i 's/\\(\\(import\\|export\\) .* from .*\\)\";/\\1\\.js\";/g' && ./node_modules/karma/bin/karma start",
"lint": "./node_modules/tslint/bin/tslint -p ./tsconfig.json",
"viz": "tsviz -recursive src/ jalhyd_class_diagram.png",
"package": "rm -rf build; npm run build && npm pack --quiet",
"package": "npm run build && npm pack --quiet",
"preprocess": "node preprocessors.js"
}
}
import { ExtraResults, ParamDefinition, ParamDomainValue, Result, ResultElement } from "../../src";
import { ExtraResults, ParamDefinition, ParamDomainValue, Result, ResultElement } from "../../src/index";
/**
* IMPORTANT !
......
......@@ -6,7 +6,7 @@
*/
// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
import { ParamCalculability, ParamValueMode } from "../../src";
import { ParamCalculability, ParamValueMode } from "../../src/index";
import { MacroRugo, MacroRugoFlowType, MacrorugoParams } from "../../src/macrorugo/macrorugo";
import { checkResult } from "../test_func";
......
import { ParamCalculability, ParamDefinition, ParamDomainValue, ParamFamily } from "../src";
import { ParamCalculability, ParamDefinition, ParamDomainValue, ParamFamily } from "../src/index";
import { Nub } from "../src/nub";
import { ParamsEquation } from "../src/param/params-equation";
import { Result } from "../src/util/result";
......
import { ParamDefinition } from "../src";
import { ParamDefinition } from "../src/index";
import { ParamDomain, ParamDomainValue } from "../src/param/param-domain";
import { Message, MessageCode } from "../src/util/message";
......
import { cSnTrapez, LinkedValue, Nub, ParallelStructure, ParallelStructureParams,
ParamsSectionTrapez, ParamValueMode, SectionParametree, Session } from "../../src";
ParamsSectionTrapez, ParamValueMode, SectionParametree, Session } from "../../src/index";
import { RegimeUniforme } from "../../src/regime_uniforme";
import { cSnCirc, ParamsSectionCirc } from "../../src/section/section_circulaire";
import { Cloisons, CloisonsParams } from "../../src/structure/cloisons";
......
......@@ -5,7 +5,7 @@
*/
// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { MessageCode } from "../../src";
import { MessageCode } from "../../src/index";
import { ParamCalculability } from "../../src/param/param-definition";
import { ParallelStructure } from "../../src/structure/parallel_structure";
import { Structure, StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
......
......@@ -6,7 +6,7 @@
*/
// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
import { MessageCode } from "../../src";
import { MessageCode } from "../../src/index";
import { CreateStructure } from "../../src/structure/factory_structure";
import { ParallelStructure } from "../../src/structure/parallel_structure";
import { ParallelStructureParams } from "../../src/structure/parallel_structure_params";
......
......@@ -6,7 +6,7 @@
*/
// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
import { MessageCode, StructureFlowMode, StructureFlowRegime } from "../../src";
import { MessageCode, StructureFlowMode, StructureFlowRegime } from "../../src/index";
import { StructureKivi, StructureKiviParams } from "../../src/structure/structure_kivi";
import { testStructure } from "./functions";
......
/**
* For getting btoa available in nodejs as a global function in jasmine tests
*/
global.Buffer = global.Buffer || require('buffer').Buffer;
if (typeof btoa === 'undefined') {
global.btoa = function (str) {
return new Buffer(str, 'binary').toString('base64');
};
}
......@@ -4,7 +4,7 @@
"**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
"../../spec/support/**/*.js"
],
"stopSpecOnExpectationFailure": false,
"random": false
......
{
"compilerOptions": {
"module": "commonjs",
},
"extends": "./tsconfig.spec.json",
}
{
"compilerOptions": {
"module": "es2015",
"outDir": "../build",
// "outFile": "../build/spec/index.spec.js",
},
"extends": "../tsconfig.json",
"include": [
"../src/**/*.ts",
......
{
"compilerOptions": {
"module": "es2015",
},
"extends": "./tsconfig.spec.json",
}
......@@ -6,7 +6,7 @@
*/
// import { describe, expect, it } from "../mock_jasmine";
import { Result, Session } from "../../src";
import { Result, Session } from "../../src/index";
import { NubTest, NubTestParams } from "../nubtest";
import { precDigits } from "../test_config";
......
import { NubTest, NubTestParams } from "../nubtest";
import { Session } from "../../src";
import { Session } from "../../src/index";
/**
* IMPORTANT !
......
import { CreateStructure, cSnCirc, cSnTrapez, LoiDebit, ParamsSectionCirc,
ParamsSectionTrapez, Session, StructureType } from "../../src";
ParamsSectionTrapez, Session, StructureType } from "../../src/index";
import { PabDimension, PabDimensionParams } from "../../src/pab/pab_dimension";
import { RegimeUniforme } from "../../src/regime_uniforme";
import { SectionParametree } from "../../src/section/section_parametree";
......
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