diff --git a/packages/pouchtype/package.json b/packages/pouchtype/package.json index c6541d0..9488f72 100644 --- a/packages/pouchtype/package.json +++ b/packages/pouchtype/package.json @@ -9,8 +9,9 @@ "src" ], "scripts": { - "test": "node ../../bin/runTests.js ./", - "pre-commit": "npm run test" + "test": "npm run build:test && mv dist/index.html ./.spec_runner.html && node ../../bin/runTests.js ./", + "pre-commit": "npm run test", + "build:test": "webpack --config webpack.test-config.js" }, "author": "Timothy Farrell (https://github.com/explorigin)", "license": "Apache-2.0", @@ -18,6 +19,12 @@ "frptools": "~3.2.1" }, "devDependencies": { - "pouchdb": "~7.0.0" + "html-webpack-plugin": "~3.2.0", + "pouchdb": "~7.0.0", + "pouchdb-find": "~7.0.0", + "pouchdb-adapter-memory": "^7.0.0", + "script-ext-html-webpack-plugin": "^2.0.1", + "webpack": "~4.10.2", + "webpack-cli": "~2.1.5" } } diff --git a/packages/pouchtype/spec/index.html b/packages/pouchtype/spec/index.html new file mode 100644 index 0000000..fd152f4 --- /dev/null +++ b/packages/pouchtype/spec/index.html @@ -0,0 +1,15 @@ + + + + + Jasmine Spec Runner v3.1.0 + + + + + + + + + + \ No newline at end of file diff --git a/packages/pouchtype/spec/typehandler.spec.js b/packages/pouchtype/spec/typehandler.spec.js index b7324c2..67123a7 100644 --- a/packages/pouchtype/spec/typehandler.spec.js +++ b/packages/pouchtype/spec/typehandler.spec.js @@ -1,6 +1,9 @@ import { TypeHandler } from '../src/index.js'; +import PouchDB from 'pouchdb'; +import PouchDBFind from 'pouchdb-find'; +import memory from 'pouchdb-adapter-memory'; -const PDB = PouchDB.plugin(find); +const PDB = PouchDB.plugin(PouchDBFind).plugin(memory); class ContactHandler extends TypeHandler { getUniqueID(doc) { diff --git a/packages/pouchtype/test.json b/packages/pouchtype/test.json deleted file mode 100644 index 2ed9e5a..0000000 --- a/packages/pouchtype/test.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "spec_dir": "spec", - "spec_files": ["**/*[sS]pec.js"], - "lib_files": [ - "node_modules/pouchdb/dist/pouchdb.js", - "node_modules/pouchdb/dist/pouchdb.memory.js", - "node_modules/pouchdb/dist/pouchdb.find.js" - ] -} diff --git a/packages/pouchtype/webpack.test-config.js b/packages/pouchtype/webpack.test-config.js new file mode 100644 index 0000000..1b298f2 --- /dev/null +++ b/packages/pouchtype/webpack.test-config.js @@ -0,0 +1,33 @@ +const path = require('path'); +const webpack = require('webpack'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin'); + +module.exports = { + context: path.resolve(__dirname, './spec'), + mode: 'development', + entry: { + livearray: './livearray.spec.js', + typehandler: './typehandler.spec.js', + watcher: './watcher.spec.js' + }, + output: { + path: path.resolve(__dirname, './dist'), + filename: '[name].bundle.js', + publicPath: '/packages/pouchtype/dist/' + }, + devServer: { + contentBase: path.join(__dirname, 'dist') + }, + module: {}, + plugins: [ + new webpack.DefinePlugin({ __DEV__: true }), + new HtmlWebpackPlugin({ + template: 'index.html', + inject: 'body' + }), + new ScriptExtHtmlWebpackPlugin({ + module: /.*/ + }) + ] +};