Liu Song’s Projects


~/Projects/chrome-devtools-protocol

git clone https://code.lsong.org/chrome-devtools-protocol

Commit

Commit
6a5b1f4ef77d0f98d158c9ee29b26ebe2f0e2470
Author
surunzi <[email protected]>
Date
2020-06-18 12:10:01 +0800 +0800
Diffstat
 .npmignore | 4 +++-
 karma.conf.js | 31 +++++++++++++++++++++++++++++++
 package.json | 9 ++++++++-
 webpack.config.js | 35 ++++++++++++++++++++---------------

test: setup


diff --git a/.npmignore b/.npmignore
index 4146c55629080d9fbb1c4e157ab641e6de17935e..995fda13fc362d8df744a13953affa13fabc62d3 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,6 +1,8 @@
+tests/
 .gitignore
 .npmignore
 tslint.json
 tsconfig.json
 webpack.config.js
-prettier.config.js
\ No newline at end of file
+prettier.config.js
+karma.conf.js
\ No newline at end of file




diff --git a/karma.conf.js b/karma.conf.js
new file mode 100644
index 0000000000000000000000000000000000000000..011c949a41a7ddfa2dd5da261c82549770092099
--- /dev/null
+++ b/karma.conf.js
@@ -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,
+  });
+};




diff --git a/package.json b/package.json
index 6d517696eececedf4262d4a6daa912f74714463c..2a1a362b25dcf4f744ef8a4dbc69d51f6c3ccd04 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,8 @@   "scripts": {
     "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",
@@ -25,7 +26,13 @@   "homepage": "https://github.com/liriliri/chobitsu#readme",
   "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",




diff --git a/tests/Runtime.spec.js b/tests/Runtime.spec.js
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
Binary files /dev/null and b/tests/Runtime.spec.js differ




diff --git a/webpack.config.js b/webpack.config.js
index 94082de4a7cd502ac5faca16e67a581fdc1ba869..f310e7e8e5f43d6203f9fe32da7a77c779e8d835 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,35 +1,40 @@
 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'),
-const path = require('path');
+module.exports = (env, argv) => {
-const path = require('path');
+module.exports = (env, argv) => {
 const path = require('path');
-const path = require('path');
+module.exports = (env, argv) => {
 
-    },
+    extensions: ['.ts', '.js'],
+module.exports = (env, argv) => {
 const path = require('path');
-module.exports = (env, argv) => {
-const path = require('path');
+module.exports = (env, argv) => {
   const config = {
-const path = require('path');
+module.exports = (env, argv) => {
     entry: './src/index.ts',
-const path = require('path');
+module.exports = (env, argv) => {
     devtool: 'source-map',
-const path = require('path');
+module.exports = (env, argv) => {
     output: {
-const path = require('path');
+module.exports = (env, argv) => {
       filename: 'chobitsu.js',
-const path = require('path');
+module.exports = (env, argv) => {
       path: path.resolve(__dirname, 'dist'),
-    },
-
+  const config = {
-
-
+module.exports = (env, argv) => {
 const path = require('path');
 };