Skip to content

Commit 7d9074a

Browse files
committed
trying to test router
1 parent 12c13a8 commit 7d9074a

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

cypress/integration/item-spec.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import VueRouter from 'vue-router'
2+
import router from '../../src/router'
13
import Item from '../../src/components/Item.vue'
24
import { timeAgo, host } from '../../src/util/filters'
35

@@ -21,34 +23,18 @@ describe('Item', () => {
2123
}
2224
}
2325
const extensions = {
26+
plugins: [VueRouter],
2427
filters: { timeAgo, host }
2528
}
26-
const html = `
27-
<html>
28-
<head></head>
29-
<body>
30-
<div id="app"></div>
31-
<script src="https://unpkg.com/vue@2.5.3"></script>
32-
</body>
33-
</html>
34-
`
35-
// <script src="https://unpkg.com/vue-router@3.0.1"></script>
36-
// hmm, when adding the vue router getting an error inside the RouterLink
37-
// render function
38-
// var router = this.$router;
39-
// var current = this.$route;
40-
// var ref = router.resolve(this.to, current, this.append);
41-
// this.$router is undefined
42-
// Seems VueRouter.install(Vue) did not go well
29+
4330
const options = {
44-
html,
4531
extensions
4632
}
4733

4834
beforeEach(() => {
4935
cy.viewport(400, 200)
5036
})
51-
beforeEach(mountVue({ template, components, data }, options))
37+
beforeEach(mountVue({ template, router, components, data }, options))
5238

5339
it('loads news item', () => {
5440
cy.contains('.score', 101)

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"start": "cross-env NODE_ENV=production node server",
99
"build": "rimraf dist && npm run build:client && npm run build:server",
1010
"build:client": "cross-env NODE_ENV=production webpack --config build/webpack.client.config.js --progress --hide-modules",
11-
"build:server": "cross-env NODE_ENV=production webpack --config build/webpack.server.config.js --progress --hide-modules"
11+
"build:server": "cross-env NODE_ENV=production webpack --config build/webpack.server.config.js --progress --hide-modules",
12+
"cy:open": "cypress open",
13+
"e2e": "start-server-and-test dev http://localhost:8080 cy:open"
1214
},
1315
"engines": {
1416
"node": ">=7.0",
@@ -39,10 +41,11 @@
3941
"chokidar": "^1.7.0",
4042
"css-loader": "^0.28.7",
4143
"cypress": "^1.4.1",
42-
"cypress-vue-unit-test": "^1.9.0",
44+
"cypress-vue-unit-test": "^1.10.0",
4345
"file-loader": "^1.1.5",
4446
"friendly-errors-webpack-plugin": "^1.6.1",
4547
"rimraf": "^2.6.2",
48+
"start-server-and-test": "^1.0.0",
4649
"stylus": "^0.54.5",
4750
"stylus-loader": "^3.0.1",
4851
"sw-precache-webpack-plugin": "^0.11.4",

0 commit comments

Comments
 (0)