diff --git a/build/webpack.cypress.config.js b/build/webpack.cypress.config.js new file mode 100644 index 000000000..15899e073 --- /dev/null +++ b/build/webpack.cypress.config.js @@ -0,0 +1,13 @@ +const path = require('path') +const merge = require('webpack-merge') +const base = require('./webpack.base.config') + +const config = merge(base, { + resolve: { + alias: { + 'create-api': './create-api-client.js' + } + } +}) + +module.exports = config \ No newline at end of file diff --git a/cypress.json b/cypress.json index 870b3cb82..3255b61ad 100644 --- a/cypress.json +++ b/cypress.json @@ -1,4 +1,4 @@ { - "baseUrl": "https://vue-hn.now.sh", + "baseUrl": "http://localhost:8080", "projectId": "b1sfu5" } diff --git a/cypress/integration/item-spec.js b/cypress/integration/item-spec.js index d4de1f3bb..60f2c8106 100644 --- a/cypress/integration/item-spec.js +++ b/cypress/integration/item-spec.js @@ -2,8 +2,10 @@ import VueRouter from 'vue-router' import router from '../../src/router' import Item from '../../src/components/Item.vue' import { timeAgo, host } from '../../src/util/filters' +import { createRouter } from '../../src/router' +import VueRouter from 'vue-router' +import mountVue from 'cypress-vue-unit-test' -const mountVue = require('cypress-vue-unit-test') /* eslint-env mocha */ /* global cy, Cypress */ describe('Item', () => { @@ -22,6 +24,7 @@ describe('Item', () => { descendants: 42 } } + const extensions = { plugins: [VueRouter], filters: { timeAgo, host } @@ -31,6 +34,8 @@ describe('Item', () => { extensions } + const router = createRouter() + beforeEach(() => { cy.viewport(400, 200) }) @@ -41,6 +46,6 @@ describe('Item', () => { }) it('has link to comments', () => { - cy.contains('router-link', '42 comments') + cy.contains('.comments-link > a', '42 comments') }) }) diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index a3bb8c08f..6512accbf 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -2,7 +2,7 @@ const join = require('path').join const { onFilePreprocessor } = require('cypress-vue-unit-test/preprocessor/webpack') -const config = join(__dirname, '../../build/webpack.base.config') +const config = join(__dirname, '../../build/webpack.cypress.config') module.exports = on => { on('file:preprocessor', onFilePreprocessor(config)) } diff --git a/package.json b/package.json index 88fc60f55..0b33d995a 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "author": "Evan You ", "private": true, "scripts": { + "cy:open": "cypress open", + "cy:run": "cypress run", "dev": "node server", "start": "cross-env NODE_ENV=production node server", "build": "rimraf dist && npm run build:client && npm run build:server",