Skip to content

Commit

Permalink
test: setup
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Jun 18, 2020
1 parent 6f0d100 commit 6a5b1f4
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
tests/
.gitignore
.npmignore
tslint.json
tsconfig.json
webpack.config.js
prettier.config.js
prettier.config.js
karma.conf.js
31 changes: 31 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const webpackCfg = require('./webpack.config');
webpackCfg.devtool = 'inline-source-map';
webpackCfg.mode = 'development';

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['mocha', 'chai'],
files: ['src/index.ts', './tests/Runtime.spec.js'],
plugins: [
'karma-mocha',
'karma-chai-plugins',
'karma-chrome-launcher',
'karma-webpack',
],
webpackServer: {
noInfo: true,
},
webpack: webpackCfg,
reporters: ['progress'],
preprocessors: {
'src/index.ts': ['webpack'],
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: ['ChromeHeadless'],
singleRun: true,
concurrency: Infinity,
});
};
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "webpack --mode=development -w",
"build": "webpack --mode=production",
"lint": "tslint src/**/*.ts",
"format": "prettier src/**/*.ts *.{js,json} --write"
"test": "karma start",
"format": "prettier src/**/*.ts *.{js,json} tests/*.js --write"
},
"repository": {
"type": "git",
Expand All @@ -25,7 +26,13 @@
"dependencies": {},
"devDependencies": {
"@types/node": "^14.0.13",
"karma": "^5.1.0",
"karma-chai-plugins": "^0.9.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-webpack": "^4.0.2",
"licia": "^1.22.0",
"mocha": "^8.0.1",
"prettier": "^2.0.5",
"ts-loader": "^7.0.5",
"tslint": "^6.1.2",
Expand Down
Empty file added tests/Runtime.spec.js
Empty file.
42 changes: 20 additions & 22 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
const path = require('path');

module.exports = (env, argv) => {
const config = {
entry: './src/index.ts',
devtool: 'source-map',
output: {
filename: 'chobitsu.js',
path: path.resolve(__dirname, 'dist'),
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
},
],
},
};

return config;
module.exports = {
entry: './src/index.ts',
devtool: 'source-map',
output: {
filename: 'chobitsu.js',
path: path.resolve(__dirname, 'dist'),
library: 'chobitsu',
libraryTarget: 'umd',
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
},
],
},
};

0 comments on commit 6a5b1f4

Please sign in to comment.