├── .gitignore ├── README.md ├── client ├── .babelrc ├── .editorconfig ├── .eslintrc.js ├── .gitignore ├── README.md ├── build │ ├── build.js │ ├── css-loaders.js │ ├── dev-client.js │ ├── dev-server.js │ ├── webpack.base.conf.js │ ├── webpack.dev.conf.js │ └── webpack.prod.conf.js ├── config.js ├── index.html ├── package.json ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── components │ │ ├── Home.vue │ │ ├── LogTime.vue │ │ ├── Sidebar.vue │ │ └── TimeEntries.vue │ └── main.js ├── static │ └── .gitkeep └── test │ ├── e2e │ ├── custom-assertions │ │ └── elementCount.js │ ├── nightwatch.conf.js │ ├── runner.js │ └── specs │ │ └── test.js │ └── unit │ ├── .eslintrc │ ├── index.js │ ├── karma.conf.js │ └── specs │ └── Hello.spec.js └── server └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log 5 | selenium-debug.log 6 | test/unit/coverage 7 | test/e2e/reports 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue.js + Node Time Tracker 2 | 3 | This repo goes along with the Vue.js + Node time tracker tutorial available at [Scotch.io](https://scotch.io). 4 | 5 | ![](https://cdn.scotch.io/9/ILKc5RKTTvuv2JbkDbSj_vue-time-5.png) 6 | 7 | ## Install and Run 8 | 9 | ```bash 10 | cd client 11 | npm install 12 | npm run dev 13 | ``` 14 | 15 | **Note:** The server code isn't ready yet :) 16 | 17 | The app will be served at `localhost:8080`. 18 | 19 | ## License 20 | 21 | MIT 22 | -------------------------------------------------------------------------------- /client/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "stage-2"], 3 | "plugins": ["transform-runtime"], 4 | "comments": false 5 | } 6 | -------------------------------------------------------------------------------- /client/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /client/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style 4 | extends: 'standard', 5 | // required to lint *.vue files 6 | plugins: [ 7 | 'html' 8 | ], 9 | // add your custom rules here 10 | 'rules': { 11 | // allow paren-less arrow functions 12 | 'arrow-parens': 0, 13 | // allow debugger during development 14 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log 5 | selenium-debug.log 6 | test/unit/coverage 7 | test/e2e/reports 8 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | # Vue.js + Node Time Tracker 2 | 3 | This repo goes along with the Vue.js + Node time tracker tutorial available at [Scotch.io](https://scotch.io). 4 | 5 | ![](https://cdn.scotch.io/9/ILKc5RKTTvuv2JbkDbSj_vue-time-5.png) 6 | 7 | ## Install and Run 8 | 9 | ```bash 10 | npm install 11 | npm run dev 12 | ``` 13 | 14 | **Note:** The server code isn't ready yet :) 15 | 16 | The app will be served at `localhost:8080`. 17 | 18 | ## License 19 | 20 | MIT 21 | -------------------------------------------------------------------------------- /client/build/build.js: -------------------------------------------------------------------------------- 1 | // https://github.com/shelljs/shelljs 2 | require('shelljs/global') 3 | env.NODE_ENV = 'production' 4 | 5 | var path = require('path') 6 | var config = require('../config') 7 | var ora = require('ora') 8 | var webpack = require('webpack') 9 | var webpackConfig = require('./webpack.prod.conf') 10 | 11 | console.log( 12 | ' Tip:\n' + 13 | ' Built files are meant to be served over an HTTP server.\n' + 14 | ' Opening index.html over file:// won\'t work.\n' 15 | ) 16 | 17 | var spinner = ora('building for production...') 18 | spinner.start() 19 | 20 | var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory) 21 | rm('-rf', assetsPath) 22 | mkdir('-p', assetsPath) 23 | cp('-R', 'static/', assetsPath) 24 | 25 | webpack(webpackConfig, function (err, stats) { 26 | spinner.stop() 27 | if (err) throw err 28 | process.stdout.write(stats.toString({ 29 | colors: true, 30 | modules: false, 31 | children: false, 32 | chunks: false, 33 | chunkModules: false 34 | }) + '\n') 35 | }) 36 | -------------------------------------------------------------------------------- /client/build/css-loaders.js: -------------------------------------------------------------------------------- 1 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 2 | 3 | module.exports = function (options) { 4 | options = options || {} 5 | // generate loader string to be used with extract text plugin 6 | function generateLoaders (loaders) { 7 | var sourceLoader = loaders.map(function (loader) { 8 | var extraParamChar 9 | if (/\?/.test(loader)) { 10 | loader = loader.replace(/\?/, '-loader?') 11 | extraParamChar = '&' 12 | } else { 13 | loader = loader + '-loader' 14 | extraParamChar = '?' 15 | } 16 | return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '') 17 | }).join('!') 18 | 19 | if (options.extract) { 20 | return ExtractTextPlugin.extract('vue-style-loader', sourceLoader) 21 | } else { 22 | return ['vue-style-loader', sourceLoader].join('!') 23 | } 24 | } 25 | 26 | // http://vuejs.github.io/vue-loader/configurations/extract-css.html 27 | return { 28 | css: generateLoaders(['css']), 29 | postcss: generateLoaders(['css']), 30 | less: generateLoaders(['css', 'less']), 31 | sass: generateLoaders(['css', 'sass?indentedSyntax']), 32 | scss: generateLoaders(['css', 'sass']), 33 | stylus: generateLoaders(['css', 'stylus']), 34 | styl: generateLoaders(['css', 'stylus']) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /client/build/dev-client.js: -------------------------------------------------------------------------------- 1 | require('eventsource-polyfill') 2 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 3 | 4 | hotClient.subscribe(function (event) { 5 | if (event.action === 'reload') { 6 | window.location.reload() 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /client/build/dev-server.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var express = require('express') 3 | var webpack = require('webpack') 4 | var config = require('../config') 5 | var proxyMiddleware = require('http-proxy-middleware') 6 | var webpackConfig = process.env.NODE_ENV === 'testing' 7 | ? require('./webpack.prod.conf') 8 | : require('./webpack.dev.conf') 9 | 10 | // default port where dev server listens for incoming traffic 11 | var port = process.env.PORT || config.dev.port 12 | // Define HTTP proxies to your custom API backend 13 | // https://github.com/chimurai/http-proxy-middleware 14 | var proxyTable = config.dev.proxyTable 15 | 16 | var app = express() 17 | var compiler = webpack(webpackConfig) 18 | 19 | var devMiddleware = require('webpack-dev-middleware')(compiler, { 20 | publicPath: webpackConfig.output.publicPath, 21 | stats: { 22 | colors: true, 23 | chunks: false 24 | } 25 | }) 26 | 27 | var hotMiddleware = require('webpack-hot-middleware')(compiler) 28 | // force page reload when html-webpack-plugin template changes 29 | compiler.plugin('compilation', function (compilation) { 30 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 31 | hotMiddleware.publish({ action: 'reload' }) 32 | cb() 33 | }) 34 | }) 35 | 36 | // proxy api requests 37 | Object.keys(proxyTable).forEach(function (context) { 38 | var options = proxyTable[context] 39 | if (typeof options === 'string') { 40 | options = { target: options } 41 | } 42 | app.use(proxyMiddleware(context, options)) 43 | }) 44 | 45 | // handle fallback for HTML5 history API 46 | app.use(require('connect-history-api-fallback')()) 47 | 48 | // serve webpack bundle output 49 | app.use(devMiddleware) 50 | 51 | // enable hot-reload and state-preserving 52 | // compilation error display 53 | app.use(hotMiddleware) 54 | 55 | // serve pure static assets 56 | var staticPath = path.join(config.build.assetsPublicPath, config.build.assetsSubDirectory) 57 | app.use(staticPath, express.static('./static')) 58 | 59 | module.exports = app.listen(port, function (err) { 60 | if (err) { 61 | console.log(err) 62 | return 63 | } 64 | console.log('Listening at http://localhost:' + port + '\n') 65 | }) 66 | -------------------------------------------------------------------------------- /client/build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var cssLoaders = require('./css-loaders') 4 | var projectRoot = path.resolve(__dirname, '../') 5 | 6 | module.exports = { 7 | entry: { 8 | app: './src/main.js' 9 | }, 10 | output: { 11 | path: config.build.assetsRoot, 12 | publicPath: config.build.assetsPublicPath, 13 | filename: '[name].js' 14 | }, 15 | resolve: { 16 | extensions: ['', '.js', '.vue'], 17 | fallback: [path.join(__dirname, '../node_modules')], 18 | alias: { 19 | 'src': path.resolve(__dirname, '../src') 20 | } 21 | }, 22 | resolveLoader: { 23 | fallback: [path.join(__dirname, '../node_modules')] 24 | }, 25 | module: { 26 | preLoaders: [ 27 | { 28 | test: /\.vue$/, 29 | loader: 'eslint', 30 | include: projectRoot, 31 | exclude: /node_modules/ 32 | }, 33 | { 34 | test: /\.js$/, 35 | loader: 'eslint', 36 | include: projectRoot, 37 | exclude: /node_modules/ 38 | } 39 | ], 40 | loaders: [ 41 | { 42 | test: /\.vue$/, 43 | loader: 'vue' 44 | }, 45 | { 46 | test: /\.js$/, 47 | loader: 'babel', 48 | include: projectRoot, 49 | exclude: /node_modules/ 50 | }, 51 | { 52 | test: /\.json$/, 53 | loader: 'json' 54 | }, 55 | { 56 | test: /\.html$/, 57 | loader: 'vue-html' 58 | }, 59 | { 60 | test: /\.(png|jpe?g|gif|svg|woff2?|eot|ttf|otf)(\?.*)?$/, 61 | loader: 'url', 62 | query: { 63 | limit: 10000, 64 | name: path.join(config.build.assetsSubDirectory, '[name].[ext]?[hash:7]') 65 | } 66 | } 67 | ] 68 | }, 69 | vue: { 70 | loaders: cssLoaders() 71 | }, 72 | eslint: { 73 | formatter: require('eslint-friendly-formatter') 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /client/build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | var webpack = require('webpack') 2 | var merge = require('webpack-merge') 3 | var baseWebpackConfig = require('./webpack.base.conf') 4 | var HtmlWebpackPlugin = require('html-webpack-plugin') 5 | 6 | // add hot-reload related code to entry chunks 7 | Object.keys(baseWebpackConfig.entry).forEach(function (name) { 8 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 9 | }) 10 | 11 | module.exports = merge(baseWebpackConfig, { 12 | // eval-source-map is faster for development 13 | devtool: '#eval-source-map', 14 | plugins: [ 15 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 16 | new webpack.optimize.OccurenceOrderPlugin(), 17 | new webpack.HotModuleReplacementPlugin(), 18 | new webpack.NoErrorsPlugin(), 19 | // https://github.com/ampedandwired/html-webpack-plugin 20 | new HtmlWebpackPlugin({ 21 | filename: 'index.html', 22 | template: 'index.html', 23 | inject: true 24 | }) 25 | ] 26 | }) 27 | -------------------------------------------------------------------------------- /client/build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var webpack = require('webpack') 4 | var merge = require('webpack-merge') 5 | var baseWebpackConfig = require('./webpack.base.conf') 6 | var cssLoaders = require('./css-loaders') 7 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 8 | var HtmlWebpackPlugin = require('html-webpack-plugin') 9 | 10 | module.exports = merge(baseWebpackConfig, { 11 | devtool: config.build.productionSourceMap ? '#source-map' : false, 12 | output: { 13 | path: config.build.assetsRoot, 14 | filename: path.join(config.build.assetsSubDirectory, '[name].[chunkhash].js'), 15 | chunkFilename: path.join(config.build.assetsSubDirectory, '[id].[chunkhash].js') 16 | }, 17 | vue: { 18 | loaders: cssLoaders({ 19 | sourceMap: config.build.productionSourceMap, 20 | extract: true 21 | }) 22 | }, 23 | plugins: [ 24 | // http://vuejs.github.io/vue-loader/workflow/production.html 25 | new webpack.DefinePlugin({ 26 | 'process.env': { 27 | NODE_ENV: '"production"' 28 | } 29 | }), 30 | new webpack.optimize.UglifyJsPlugin({ 31 | compress: { 32 | warnings: false 33 | } 34 | }), 35 | new webpack.optimize.OccurenceOrderPlugin(), 36 | // extract css into its own file 37 | new ExtractTextPlugin(path.join(config.build.assetsSubDirectory, '[name].[contenthash].css')), 38 | // generate dist index.html with correct asset hash for caching. 39 | // you can customize output by editing /index.html 40 | // see https://github.com/ampedandwired/html-webpack-plugin 41 | new HtmlWebpackPlugin({ 42 | filename: process.env.NODE_ENV === 'testing' 43 | ? 'index.html' 44 | : config.build.index, 45 | template: 'index.html', 46 | inject: true, 47 | minify: { 48 | removeComments: true, 49 | collapseWhitespace: true, 50 | removeAttributeQuotes: true 51 | // more options: 52 | // https://github.com/kangax/html-minifier#options-quick-reference 53 | } 54 | }) 55 | ] 56 | }) 57 | -------------------------------------------------------------------------------- /client/config.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | 4 | module.exports = { 5 | build: { 6 | index: path.resolve(__dirname, 'dist/index.html'), 7 | assetsRoot: path.resolve(__dirname, 'dist'), 8 | assetsSubDirectory: 'static', 9 | assetsPublicPath: '/', 10 | productionSourceMap: true 11 | }, 12 | dev: { 13 | port: 8080, 14 | proxyTable: {} 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Vue Time Tracker 6 | 7 | 8 | 9 |
10 | 11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-time-test", 3 | "version": "0.1.0", 4 | "description": "A Vue.js project", 5 | "author": "Ryan Chenkie ", 6 | "scripts": { 7 | "dev": "node build/dev-server.js", 8 | "build": "node build/build.js", 9 | "unit": "karma start test/unit/karma.conf.js --single-run", 10 | "e2e": "node test/e2e/runner.js", 11 | "test": "npm run unit && npm run e2e" 12 | }, 13 | "dependencies": { 14 | "vue": "^1.0.18", 15 | "babel-runtime": "^5.8.0", 16 | "vue-resource": "^0.7.0", 17 | "vue-router": "^0.7.12" 18 | }, 19 | "devDependencies": { 20 | "babel-core": "^6.0.0", 21 | "babel-loader": "^6.0.0", 22 | "babel-plugin-transform-runtime": "^6.0.0", 23 | "babel-preset-es2015": "^6.0.0", 24 | "babel-preset-stage-2": "^6.0.0", 25 | "chai": "^3.5.0", 26 | "chromedriver": "^2.21.2", 27 | "connect-history-api-fallback": "^1.1.0", 28 | "cross-spawn": "^2.1.5", 29 | "css-loader": "^0.23.0", 30 | "eslint": "^2.0.0", 31 | "eslint-config-standard": "^5.1.0", 32 | "eslint-friendly-formatter": "^1.2.2", 33 | "eslint-loader": "^1.3.0", 34 | "eslint-plugin-html": "^1.3.0", 35 | "eslint-plugin-promise": "^1.0.8", 36 | "eslint-plugin-standard": "^1.3.2", 37 | "eventsource-polyfill": "^0.9.6", 38 | "express": "^4.13.3", 39 | "extract-text-webpack-plugin": "^1.0.1", 40 | "file-loader": "^0.8.4", 41 | "function-bind": "^1.0.2", 42 | "html-webpack-plugin": "^2.8.1", 43 | "http-proxy-middleware": "^0.12.0", 44 | "inject-loader": "^2.0.1", 45 | "isparta-loader": "^2.0.0", 46 | "json-loader": "^0.5.4", 47 | "karma": "^0.13.15", 48 | "karma-coverage": "^0.5.5", 49 | "karma-mocha": "^0.2.2", 50 | "karma-phantomjs-launcher": "^1.0.0", 51 | "karma-sinon-chai": "^1.2.0", 52 | "karma-sourcemap-loader": "^0.3.7", 53 | "karma-spec-reporter": "0.0.24", 54 | "karma-webpack": "^1.7.0", 55 | "lolex": "^1.4.0", 56 | "mocha": "^2.4.5", 57 | "nightwatch": "^0.8.18", 58 | "ora": "^0.2.0", 59 | "phantomjs-prebuilt": "^2.1.3", 60 | "selenium-server": "2.53.0", 61 | "shelljs": "^0.6.0", 62 | "sinon": "^1.17.3", 63 | "sinon-chai": "^2.8.0", 64 | "url-loader": "^0.5.7", 65 | "vue-hot-reload-api": "^1.2.0", 66 | "vue-html-loader": "^1.0.0", 67 | "vue-loader": "^8.2.1", 68 | "vue-style-loader": "^1.0.0", 69 | "webpack": "^1.12.2", 70 | "webpack-dev-middleware": "^1.4.0", 71 | "webpack-hot-middleware": "^2.6.0", 72 | "webpack-merge": "^0.8.3" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /client/src/App.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 53 | -------------------------------------------------------------------------------- /client/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenkie/vue-node-time-tracker/1dde1b803b94b999d55ede48ff2212a08b2f186d/client/src/assets/logo.png -------------------------------------------------------------------------------- /client/src/components/Home.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/src/components/LogTime.vue: -------------------------------------------------------------------------------- 1 | 40 | 41 | -------------------------------------------------------------------------------- /client/src/components/Sidebar.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | -------------------------------------------------------------------------------- /client/src/components/TimeEntries.vue: -------------------------------------------------------------------------------- 1 | 66 | 67 | 106 | 107 | -------------------------------------------------------------------------------- /client/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import Home from './components/Home.vue' 4 | import TimeEntries from './components/TimeEntries.vue' 5 | import LogTime from './components/LogTime.vue' 6 | import VueRouter from 'vue-router' 7 | import VueResource from 'vue-resource' 8 | 9 | // We want to apply VueResource and VueRouter 10 | // to our Vue instance 11 | Vue.use(VueResource) 12 | Vue.use(VueRouter) 13 | 14 | const router = new VueRouter() 15 | 16 | // Pointing routes to the components they should use 17 | router.map({ 18 | '/home': { 19 | component: Home 20 | }, 21 | '/time-entries': { 22 | component: TimeEntries, 23 | subRoutes: { 24 | '/log-time': { 25 | component: LogTime 26 | } 27 | } 28 | } 29 | }) 30 | 31 | // Any invalid route will redirect to home 32 | router.redirect({ 33 | '*': '/home' 34 | }) 35 | 36 | router.start(App, '#app') 37 | -------------------------------------------------------------------------------- /client/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenkie/vue-node-time-tracker/1dde1b803b94b999d55ede48ff2212a08b2f186d/client/static/.gitkeep -------------------------------------------------------------------------------- /client/test/e2e/custom-assertions/elementCount.js: -------------------------------------------------------------------------------- 1 | // A custom Nightwatch assertion. 2 | // the name of the method is the filename. 3 | // can be used in tests like this: 4 | // 5 | // browser.assert.elementCount(selector, count) 6 | // 7 | // for how to write custom assertions see 8 | // http://nightwatchjs.org/guide#writing-custom-assertions 9 | exports.assertion = function (selector, count) { 10 | this.message = 'Testing if element <' + selector + '> has count: ' + count 11 | this.expected = count 12 | this.pass = function (val) { 13 | return val === this.expected 14 | } 15 | this.value = function (res) { 16 | return res.value 17 | } 18 | this.command = function (cb) { 19 | var self = this 20 | return this.api.execute(function (selector) { 21 | return document.querySelectorAll(selector).length 22 | }, [selector], function (res) { 23 | cb.call(self, res) 24 | }) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /client/test/e2e/nightwatch.conf.js: -------------------------------------------------------------------------------- 1 | // http://nightwatchjs.org/guide#settings-file 2 | module.exports = { 3 | "src_folders": ["test/e2e/specs"], 4 | "output_folder": "test/e2e/reports", 5 | "custom_assertions_path": ["test/e2e/custom-assertions"], 6 | 7 | "selenium": { 8 | "start_process": true, 9 | "server_path": "node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.0.jar", 10 | "host": "127.0.0.1", 11 | "port": 4444, 12 | "cli_args": { 13 | "webdriver.chrome.driver": require('chromedriver').path 14 | } 15 | }, 16 | 17 | "test_settings": { 18 | "default": { 19 | "selenium_port": 4444, 20 | "selenium_host": "localhost", 21 | "silent": true 22 | }, 23 | 24 | "chrome": { 25 | "desiredCapabilities": { 26 | "browserName": "chrome", 27 | "javascriptEnabled": true, 28 | "acceptSslCerts": true 29 | } 30 | }, 31 | 32 | "firefox": { 33 | "desiredCapabilities": { 34 | "browserName": "firefox", 35 | "javascriptEnabled": true, 36 | "acceptSslCerts": true 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /client/test/e2e/runner.js: -------------------------------------------------------------------------------- 1 | // 1. start the dev server using production config 2 | process.env.NODE_ENV = 'testing' 3 | var server = require('../../build/dev-server.js') 4 | 5 | // 2. run the nightwatch test suite against it 6 | // to run in additional browsers: 7 | // 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings" 8 | // 2. add it to the --env flag below 9 | // For more information on Nightwatch's config file, see 10 | // http://nightwatchjs.org/guide#settings-file 11 | var spawn = require('cross-spawn') 12 | var runner = spawn( 13 | './node_modules/.bin/nightwatch', 14 | [ 15 | '--config', 'test/e2e/nightwatch.conf.js', 16 | '--env', 'chrome,firefox' 17 | ], 18 | { 19 | stdio: 'inherit' 20 | } 21 | ) 22 | 23 | runner.on('exit', function (code) { 24 | server.close() 25 | process.exit(code) 26 | }) 27 | 28 | runner.on('error', function (err) { 29 | server.close() 30 | throw err 31 | }) 32 | -------------------------------------------------------------------------------- /client/test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function (browser) { 6 | browser 7 | .url('http://localhost:8080') 8 | .waitForElementVisible('#app', 5000) 9 | .assert.elementPresent('.logo') 10 | .assert.containsText('h1', 'Hello World!') 11 | .assert.elementCount('p', 3) 12 | .end() 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /client/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | }, 5 | "globals": { 6 | "expect": true, 7 | "sinon": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /client/test/unit/index.js: -------------------------------------------------------------------------------- 1 | // Polyfill fn.bind() for PhantomJS 2 | /* eslint-disable no-extend-native */ 3 | Function.prototype.bind = require('function-bind') 4 | 5 | // require all test files (files that ends with .spec.js) 6 | var testsContext = require.context('./specs', true, /\.spec$/) 7 | testsContext.keys().forEach(testsContext) 8 | 9 | // require all src files except main.js for coverage. 10 | // you can also change this to match only the subset of files that 11 | // you want coverage for. 12 | var srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/) 13 | srcContext.keys().forEach(srcContext) 14 | -------------------------------------------------------------------------------- /client/test/unit/karma.conf.js: -------------------------------------------------------------------------------- 1 | // This is a karma config file. For more details see 2 | // http://karma-runner.github.io/0.13/config/configuration-file.html 3 | // we are also using it with karma-webpack 4 | // https://github.com/webpack/karma-webpack 5 | 6 | var path = require('path') 7 | var merge = require('webpack-merge') 8 | var baseConfig = require('../../build/webpack.base.conf') 9 | var projectRoot = path.resolve(__dirname, '../../') 10 | 11 | var webpackConfig = merge(baseConfig, { 12 | // use inline sourcemap for karma-sourcemap-loader 13 | devtool: '#inline-source-map', 14 | vue: { 15 | loaders: { 16 | js: 'isparta' 17 | } 18 | } 19 | }) 20 | 21 | // no need for app entry during tests 22 | delete webpackConfig.entry 23 | 24 | // make sure isparta loader is applied before eslint 25 | webpackConfig.module.preLoaders = webpackConfig.module.preLoaders || [] 26 | webpackConfig.module.preLoaders.unshift({ 27 | test: /\.js$/, 28 | loader: 'isparta', 29 | include: projectRoot, 30 | exclude: /test\/unit|node_modules/ 31 | }) 32 | 33 | // only apply babel for test files when using isparta 34 | webpackConfig.module.loaders.some(function (loader, i) { 35 | if (loader.loader === 'babel') { 36 | loader.include = /test\/unit/ 37 | return true 38 | } 39 | }) 40 | 41 | module.exports = function (config) { 42 | config.set({ 43 | // to run in additional browsers: 44 | // 1. install corresponding karma launcher 45 | // http://karma-runner.github.io/0.13/config/browsers.html 46 | // 2. add it to the `browsers` array below. 47 | browsers: ['PhantomJS'], 48 | frameworks: ['mocha', 'sinon-chai'], 49 | reporters: ['spec', 'coverage'], 50 | files: ['./index.js'], 51 | preprocessors: { 52 | './index.js': ['webpack', 'sourcemap'] 53 | }, 54 | webpack: webpackConfig, 55 | webpackMiddleware: { 56 | noInfo: true 57 | }, 58 | coverageReporter: { 59 | dir: './coverage', 60 | reporters: [ 61 | { type: 'lcov', subdir: '.' }, 62 | { type: 'text-summary' } 63 | ] 64 | } 65 | }) 66 | } 67 | -------------------------------------------------------------------------------- /client/test/unit/specs/Hello.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Hello from 'src/components/Hello' 3 | 4 | describe('Hello.vue', () => { 5 | it('should render correct contents', () => { 6 | const vm = new Vue({ 7 | template: '
', 8 | components: { Hello } 9 | }).$mount() 10 | expect(vm.$el.querySelector('.hello h1').textContent).to.contain('Hello World!') 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /server/README.md: -------------------------------------------------------------------------------- 1 | # NodeJS App for the Vue.js Time Tracker 2 | 3 | TODO: Build the Node app :) --------------------------------------------------------------------------------