chore(build): remove karma preprocessors
Custom karma preprocessors are no longer being used after 1676 and 1597
This commit is contained in:
parent
be7504d451
commit
01fdb4afc6
|
@ -155,7 +155,7 @@ You can selectively run either the JS or Dart versions as follows:
|
||||||
|
|
||||||
You can run just the unit tests as follows:
|
You can run just the unit tests as follows:
|
||||||
|
|
||||||
* `$(npm bin)/gulp test.unit.js`: JS tests in a browser; runs in **watch mode** (i.e. karma
|
* `$(npm bin)/gulp test.unit.js`: JS tests in a browser; runs in **watch mode** (i.e.
|
||||||
watches the test files for changes and re-runs tests when files are updated).
|
watches the test files for changes and re-runs tests when files are updated).
|
||||||
* `$(npm bin)/gulp test.unit.cjs`: JS tests in NodeJS; runs in **watch mode**.
|
* `$(npm bin)/gulp test.unit.cjs`: JS tests in NodeJS; runs in **watch mode**.
|
||||||
* `$(npm bin)/gulp test.unit.dart`: Dart tests in Dartium; runs in **watch mode**.
|
* `$(npm bin)/gulp test.unit.dart`: Dart tests in Dartium; runs in **watch mode**.
|
||||||
|
@ -166,15 +166,14 @@ If you prefer running tests in "single-run" mode rather than watch mode use:
|
||||||
* `$(npm bin)/gulp test.unit.cjs/ci`
|
* `$(npm bin)/gulp test.unit.cjs/ci`
|
||||||
* `$(npm bin)/gulp test.unit.dart/ci`
|
* `$(npm bin)/gulp test.unit.dart/ci`
|
||||||
|
|
||||||
|
The task updates the dist folder with transpiled code whenever a source or test file changes, and
|
||||||
|
Karma is run against the new output.
|
||||||
|
|
||||||
**Note**: If you want to only run a single test you can alter the test you wish to run by changing
|
**Note**: If you want to only run a single test you can alter the test you wish to run by changing
|
||||||
`it` to `iit` or `describe` to `ddescribe`. This will only run that individual test and make it
|
`it` to `iit` or `describe` to `ddescribe`. This will only run that individual test and make it
|
||||||
much easier to debug. `xit` and `xdescribe` can also be useful to exclude a test and a group of
|
much easier to debug. `xit` and `xdescribe` can also be useful to exclude a test and a group of
|
||||||
tests respectively.
|
tests respectively.
|
||||||
|
|
||||||
**Note for transpiler tests**: The karma preprocessor is setup in a way so that after every test
|
|
||||||
run the transpiler is reloaded. With that it is possible to make changes to the preprocessor and
|
|
||||||
run the tests without exiting karma (just touch a test file that you would like to run).
|
|
||||||
|
|
||||||
### E2e tests
|
### E2e tests
|
||||||
|
|
||||||
1. `$(npm bin)/gulp build.js.cjs` (builds benchpress and tests into `dist/js/cjs` folder).
|
1. `$(npm bin)/gulp build.js.cjs` (builds benchpress and tests into `dist/js/cjs` folder).
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
karma-js.conf.js
|
|
|
@ -1,56 +0,0 @@
|
||||||
var transpiler = require('./index.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
'preprocessor:traceur': ['factory', createJs2DartPreprocessor]
|
|
||||||
};
|
|
||||||
|
|
||||||
function createJs2DartPreprocessor(logger, basePath, config, emitter) {
|
|
||||||
var log = logger.create('traceur');
|
|
||||||
// Reload the transpiler sources so we don't need to
|
|
||||||
// restart karma when we made changes to traceur.
|
|
||||||
// As there is no event that is called before any preprocessor runs,
|
|
||||||
// we listen for the end event in karma to reload the
|
|
||||||
// transpiler sources.
|
|
||||||
emitter.on('run_complete', function(filesPromise) {
|
|
||||||
transpiler.reloadSources();
|
|
||||||
});
|
|
||||||
return function(content, file, done) {
|
|
||||||
try {
|
|
||||||
var moduleName = config.resolveModuleName(file.originalPath);
|
|
||||||
if (config.transformPath) {
|
|
||||||
file.path = config.transformPath(file.originalPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = transpiler.compile(config.options, {
|
|
||||||
inputPath: file.originalPath,
|
|
||||||
outputPath: file.path,
|
|
||||||
moduleName: moduleName
|
|
||||||
}, content, true);
|
|
||||||
|
|
||||||
var transpiledContent = result.js;
|
|
||||||
var sourceMap = result.sourceMap;
|
|
||||||
|
|
||||||
if (sourceMap) {
|
|
||||||
transpiledContent += '\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,';
|
|
||||||
transpiledContent += new Buffer(JSON.stringify(sourceMap)).toString('base64') + '\n';
|
|
||||||
file.sourceMap = sourceMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
done(null, transpiledContent);
|
|
||||||
} catch (errors) {
|
|
||||||
var errorString;
|
|
||||||
if (errors.forEach) {
|
|
||||||
errors.forEach(function(error) {
|
|
||||||
log.error(error);
|
|
||||||
});
|
|
||||||
errorString = errors.join('\n');
|
|
||||||
} else {
|
|
||||||
log.error(errors);
|
|
||||||
errorString = errors;
|
|
||||||
}
|
|
||||||
done(new Error('TRACEUR COMPILE ERRORS\n' + errorString));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
createJs2DartPreprocessor.$inject = ['logger', 'config.basePath', 'config.traceurPreprocessor', 'emitter'];
|
|
|
@ -1,36 +0,0 @@
|
||||||
// Transpiles JavaScript and TypeScript code to Dart using ts2dart.
|
|
||||||
|
|
||||||
var ts2dart = require('ts2dart');
|
|
||||||
var rundartpackage = require('../build/rundartpackage.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
'preprocessor:ts2dart': ['factory', createTs2DartPreprocessor]
|
|
||||||
};
|
|
||||||
|
|
||||||
function createTs2DartPreprocessor(logger, basePath, config, emitter) {
|
|
||||||
var log = logger.create('ts2dart');
|
|
||||||
return function(content, file, done) {
|
|
||||||
try {
|
|
||||||
var moduleName = config.resolveModuleName(file.originalPath);
|
|
||||||
file.path = config.transformPath(file.originalPath);
|
|
||||||
var transpiler = new ts2dart.Transpiler(
|
|
||||||
{failFast: false, generateLibraryName: true, generateSourceMap: true});
|
|
||||||
var transpiledContent = transpiler.translateFile(file.originalPath, moduleName);
|
|
||||||
// TODO(martinprobst): Source maps.
|
|
||||||
done(null, transpiledContent);
|
|
||||||
} catch (errors) {
|
|
||||||
var errorString;
|
|
||||||
if (errors.forEach) {
|
|
||||||
errors.forEach(function(error) { log.error(error); });
|
|
||||||
errorString = errors.join('\n');
|
|
||||||
} else {
|
|
||||||
log.error(errors);
|
|
||||||
errorString = errors;
|
|
||||||
}
|
|
||||||
done(new Error('ts2dart compile errors:\n' + errorString));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
createTs2DartPreprocessor
|
|
||||||
.$inject = ['logger', 'config.basePath', 'config.ts2dartPreprocessor', 'emitter'];
|
|
Loading…
Reference in New Issue