Skip to content

Commit 98728ba

Browse files
authored
Add travis and tests (#2)
* Add travis and tests Signed-off-by: Finnian Anderson <[email protected]> * Use Sauce Labs Signed-off-by: Finnian Anderson <[email protected]> * Fix tests? Signed-off-by: Finnian Anderson <[email protected]> * Fix tests? Signed-off-by: Finnian Anderson <[email protected]> * Fix tests? Signed-off-by: Finnian Anderson <[email protected]> * Fix tests again? Signed-off-by: Finnian Anderson <[email protected]> * Remove iojs task Signed-off-by: Finnian Anderson <[email protected]> * Add coverage and badges Signed-off-by: Finnian Anderson <[email protected]> * Add codecov badge Signed-off-by: Finnian Anderson <[email protected]>
1 parent f87093d commit 98728ba

File tree

11 files changed

+205
-78
lines changed

11 files changed

+205
-78
lines changed

.travis.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
node_js:
3+
- "10"
4+
install:
5+
- npm install
6+
- npm install -g codecov
7+
after_script:
8+
- npm run report-coverage
9+
env:
10+
global:
11+
- SAUCE_USERNAME="developius"
12+
- CC_TEST_REPORTER_ID="9b0f8a7fea8537a42e55686a95276049d620f387463ef98af52142eebc19ed5f"
13+
addons:
14+
sauce_connect: true

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
12
# swapi-vue-pwa
23
Progressive Web App built with Vue using data from the [Star Wars API](https://swapi.co).
34

5+
[![Build Status](https://travis-ci.com/developius/swapi-vue-pwa.svg?branch=master)](https://travis-ci.com/developius/swapi-vue-pwa) [![Dependencies](https://david-dm.org/developius/swapi-vue-pwa.svg)](https://david-dm.org/developius/swapi-vue-pwa)
6+
[![codecov](https://codecov.io/gh/developius/swapi-vue-pwa/branch/master/graph/badge.svg)](https://codecov.io/gh/developius/swapi-vue-pwa)
7+
48
![SWAPI PWA screenshot](https://finnian.io/blog/content/images/2018/08/SWAPI-PWA.png)
59

610
Hosted version deployed with Now: [swapi.finnian.app](https://swapi.finnian.app)

package-lock.json

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+29-25
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,48 @@
55
"author": "Finnian Anderson <[email protected]>",
66
"private": true,
77
"scripts": {
8+
"report-coverage": "codecov",
89
"dev": "node build/dev-server.js",
910
"start": "serve -n dist",
1011
"build": "NODE_ENV=production node build/build.js",
1112
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
1213
"e2e": "node test/e2e/runner.js",
1314
"test": "npm run unit && npm run e2e",
15+
"unit-watch": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --auto-watch",
1416
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
1517
},
1618
"dependencies": {
17-
"axios": "^0.18.0",
18-
"lodash.debounce": "^4.0.8",
19-
"serve": "^9.4.0",
20-
"vue": "^2.5.2",
21-
"vue-analytics": "^5.12.3",
22-
"vue-meta": "^1.5.2",
23-
"vue-moment": "^4.0.0",
24-
"vue-router": "^3.0.1"
19+
"serve": "^9.4.0"
2520
},
2621
"devDependencies": {
22+
"@vue/test-utils": "^1.0.0-beta.24",
2723
"autoprefixer": "^7.1.5",
24+
"axios": "^0.18.0",
2825
"babel-core": "^6.26.0",
29-
"sw-precache-webpack-plugin": "^0.11.4",
3026
"babel-eslint": "^8.0.1",
3127
"babel-loader": "^7.1.2",
28+
"babel-plugin-istanbul": "^4.1.5",
3229
"babel-plugin-transform-runtime": "^6.23.0",
30+
"babel-polyfill": "^6.26.0",
3331
"babel-preset-env": "^1.6.0",
3432
"babel-preset-stage-2": "^6.24.1",
3533
"babel-register": "^6.26.0",
34+
"chai": "^4.1.2",
3635
"chalk": "^2.1.0",
36+
"chromedriver": "^2.33.1",
3737
"connect-history-api-fallback": "^1.4.0",
3838
"copy-webpack-plugin": "^4.1.1",
39+
"cross-env": "^5.0.5",
40+
"cross-spawn": "^5.1.0",
3941
"css-loader": "^0.28.7",
4042
"cssnano": "^3.10.0",
4143
"eslint": "^4.9.0",
44+
"eslint-config-standard": "^10.2.1",
4245
"eslint-friendly-formatter": "^3.0.0",
4346
"eslint-loader": "^1.9.0",
4447
"eslint-plugin-html": "^3.2.2",
4548
"eslint-plugin-import": "^2.7.0",
4649
"eslint-plugin-node": "^5.2.0",
47-
"eslint-config-standard": "^10.2.1",
4850
"eslint-plugin-promise": "^3.6.0",
4951
"eslint-plugin-standard": "^3.0.1",
5052
"eventsource-polyfill": "^0.9.6",
@@ -54,8 +56,7 @@
5456
"friendly-errors-webpack-plugin": "^1.6.1",
5557
"html-webpack-plugin": "^2.30.1",
5658
"http-proxy-middleware": "^0.17.4",
57-
"webpack-bundle-analyzer": "^2.9.0",
58-
"cross-env": "^5.0.5",
59+
"inject-loader": "^3.0.1",
5960
"karma": "^1.7.1",
6061
"karma-coverage": "^1.1.1",
6162
"karma-mocha": "^1.3.0",
@@ -65,32 +66,35 @@
6566
"karma-sourcemap-loader": "^0.3.7",
6667
"karma-spec-reporter": "0.0.31",
6768
"karma-webpack": "^2.0.5",
69+
"lodash.debounce": "^4.0.8",
6870
"mocha": "^4.0.1",
69-
"chai": "^4.1.2",
70-
"sinon": "^4.0.1",
71-
"sinon-chai": "^2.14.0",
72-
"inject-loader": "^3.0.1",
73-
"babel-plugin-istanbul": "^4.1.5",
74-
"phantomjs-prebuilt": "^2.1.15",
75-
"chromedriver": "^2.33.1",
76-
"cross-spawn": "^5.1.0",
7771
"nightwatch": "^0.9.16",
78-
"selenium-server": "^3.6.0",
79-
"semver": "^5.4.1",
80-
"shelljs": "^0.7.8",
8172
"opn": "^5.1.0",
8273
"optimize-css-assets-webpack-plugin": "^3.2.0",
8374
"ora": "^1.3.0",
75+
"phantomjs-prebuilt": "^2.1.15",
8476
"rimraf": "^2.6.2",
77+
"selenium-server": "^3.6.0",
78+
"semver": "^5.4.1",
79+
"shelljs": "^0.7.8",
80+
"sinon": "^4.0.1",
81+
"sinon-chai": "^2.14.0",
82+
"sw-precache-webpack-plugin": "^0.11.4",
83+
"uglify-es": "^3.1.3",
8584
"url-loader": "^0.6.2",
85+
"vue": "^2.5.2",
86+
"vue-analytics": "^5.12.3",
8687
"vue-loader": "^13.3.0",
88+
"vue-meta": "^1.5.2",
89+
"vue-moment": "^4.0.0",
90+
"vue-router": "^3.0.1",
8791
"vue-style-loader": "^3.0.3",
8892
"vue-template-compiler": "^2.5.2",
8993
"webpack": "^3.7.1",
94+
"webpack-bundle-analyzer": "^2.9.0",
9095
"webpack-dev-middleware": "^1.12.0",
9196
"webpack-hot-middleware": "^2.19.1",
92-
"webpack-merge": "^4.1.0",
93-
"uglify-es": "^3.1.3"
97+
"webpack-merge": "^4.1.0"
9498
},
9599
"engines": {
96100
"node": ">= 4.0.0",

src/components/Hello.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default {
121121
watch: {
122122
query (value) {
123123
if (value) this.search()
124-
else this.clearSelectedEntity()
124+
else this.clearResults()
125125
},
126126
selectedEntity () {
127127
if (this.query) this.search()

src/main.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ const isProd = process.env.NODE_ENV === 'production'
1111

1212
Vue.use(require('vue-moment'))
1313
Vue.use(Meta)
14-
Vue.use(VueAnalytics, {
15-
id: 'UA-73944565-5',
16-
router,
17-
debug: {
18-
enabled: !isProd,
19-
sendHitTask: isProd
20-
}
21-
})
14+
if (isProd) {
15+
Vue.use(VueAnalytics, {
16+
id: 'UA-73944565-5',
17+
router,
18+
debug: {
19+
enabled: !isProd,
20+
sendHitTask: isProd
21+
}
22+
})
23+
}
2224

2325
/* eslint-disable no-new */
2426
new Vue({

test/e2e/nightwatch.conf.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
require('babel-register')
22
var config = require('../../config')
33

4+
const TRAVIS = process.env.TRAVIS_JOB_NUMBER ? true : false
5+
const TRAVIS_JOB_NUMBER = process.env.TRAVIS_JOB_NUMBER
6+
47
// http://nightwatchjs.org/gettingstarted#settings-file
58
module.exports = {
69
src_folders: ['test/e2e/specs'],
@@ -19,8 +22,10 @@ module.exports = {
1922

2023
test_settings: {
2124
default: {
22-
selenium_port: 4444,
23-
selenium_host: 'localhost',
25+
selenium_port: TRAVIS ? 80 : 4444,
26+
selenium_host: TRAVIS ? 'ondemand.saucelabs.com' : 'localhost',
27+
username: TRAVIS ? process.env.SAUCE_USERNAME : undefined,
28+
password: TRAVIS ? process.env.SAUCE_ACCESS_KEY : undefined,
2429
silent: true,
2530
globals: {
2631
devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
@@ -31,7 +36,9 @@ module.exports = {
3136
desiredCapabilities: {
3237
browserName: 'chrome',
3338
javascriptEnabled: true,
34-
acceptSslCerts: true
39+
acceptSslCerts: true,
40+
build: `build-${TRAVIS_JOB_NUMBER}`,
41+
'tunnel-identifier': TRAVIS_JOB_NUMBER,
3542
}
3643
},
3744

test/e2e/specs/test.js

-5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ module.exports = {
1111
browser
1212
.url(devServer)
1313
.waitForElementVisible('#app', 5000)
14-
.assert.elementPresent('.hello')
1514
.assert.elementPresent('input')
16-
.assert.containsText('h1', 'Your name is')
17-
.setValue('input', 'Finnian Anderson')
18-
.assert.containsText('h1', 'Your name is Finnian Anderson')
19-
.assert.elementCount('img', 1)
2015
.end()
2116
}
2217
}

test/unit/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import Vue from 'vue'
2-
3-
Vue.config.productionTip = false
1+
require('../../src/main.js')
42

53
// require all test files (files that ends with .spec.js)
64
const testsContext = require.context('./specs', true, /\.spec$/)

test/unit/karma.conf.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ module.exports = function (config) {
1414
browsers: ['PhantomJS'],
1515
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
1616
reporters: ['spec', 'coverage'],
17-
files: ['./index.js'],
17+
files: [
18+
'../../node_modules/babel-polyfill/dist/polyfill.js',
19+
'./index.js'
20+
],
1821
preprocessors: {
1922
'./index.js': ['webpack', 'sourcemap']
2023
},
@@ -26,6 +29,7 @@ module.exports = function (config) {
2629
dir: './coverage',
2730
reporters: [
2831
{ type: 'lcov', subdir: '.' },
32+
{ type: 'json', subdir: '.' },
2933
{ type: 'text-summary' }
3034
]
3135
}

0 commit comments

Comments
 (0)