Skip to content

Commit

Permalink
updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mschile committed Dec 3, 2024
1 parent dcbbe4a commit 5cf6026
Show file tree
Hide file tree
Showing 27 changed files with 122 additions and 174 deletions.
4 changes: 4 additions & 0 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,10 @@ jobs:
- run:
name: Build
command: yarn lerna run build --scope=@cypress/vue
- run:
name: Run tests
command: yarn test
working_directory: npm/vue
- store_test_results:
path: npm/vue/test_results
- store_artifacts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import mockUsers from './user.list.json'

// import everything from "axios" module
// so we can mock its methods from the test
const Axios = require('axios')
import Axios from 'axios'

describe('Mocking get import from Axios', () => {
// TODO: fix with https://github.com/cypress-io/cypress/issues/30706
describe.skip('Mocking get import from Axios', () => {
it('renders mocked data', () => {
cy.stub(Axios, 'get')
.resolves({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import mockUsers from './user.list.json'

// import everything from "axios" module
// so we can mock its methods from the test
const Axios = require('axios')
import Axios from 'axios'

describe('Mocking get import from Axios', () => {
// TODO: fix with https://github.com/cypress-io/cypress/issues/30706
describe.skip('Mocking get import from Axios', () => {
it('renders mocked data', () => {
cy.stub(Axios, 'get')
.resolves({
Expand Down
27 changes: 0 additions & 27 deletions npm/vue/cypress/component/advanced/mocking-axios/3-Users.cy.js

This file was deleted.

34 changes: 0 additions & 34 deletions npm/vue/cypress/component/advanced/mocking-axios/3-Users.vue

This file was deleted.

2 changes: 0 additions & 2 deletions npm/vue/cypress/component/advanced/mocking-axios/AxiosApi.js

This file was deleted.

8 changes: 5 additions & 3 deletions npm/vue/cypress/component/alert/alert.cy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import AlertMessage from './AlertMessage.vue'
import { mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'

/* eslint-env mocha */
describe('AlertMessage', () => {
beforeEach(mountCallback(AlertMessage))
beforeEach(() => {
mount(AlertMessage)
})

it('loads', () => {
cy.get('button').should('be.visible')
})
Expand Down
2 changes: 1 addition & 1 deletion npm/vue/cypress/component/basic/components/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# global components

During mounting, you can register other components, even fake ones. See [spec.js](spec.js)
During mounting, you can register other components, even fake ones. See [spec.cy.js](spec.cy.js)

```js
import MessageList from '../MessageList.vue'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/// <reference types="cypress" />
import MessageList from '../MessageList.vue'
import { mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'

// common utils for MessageList
const getItems = () => cy.get('ul li')

describe('Global components', () => {
// TODO: fix with https://github.com/cypress-io/cypress/issues/30706
describe.skip('Global components', () => {
// two different components, each gets "numbers" list
// into its property "messages"
const template = `
Expand All @@ -26,7 +27,9 @@ describe('Global components', () => {
components,
}

beforeEach(mountCallback({ template, data }, { extensions }))
beforeEach(() => {
mount({ template, data }, { extensions })
})

it('shows two items at the start in both lists', () => {
getItems().should('have.length', 4)
Expand Down
10 changes: 6 additions & 4 deletions npm/vue/cypress/component/basic/list.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'

/* eslint-env mocha */
describe('Declarative rendering', () => {
// TODO: fix with https://github.com/cypress-io/cypress/issues/30706
describe.skip('Declarative rendering', () => {
// List example from https://vuejs.org/v2/guide/#Declarative-Rendering
const template = `
<ol>
Expand All @@ -21,7 +21,9 @@ describe('Declarative rendering', () => {
}
}

beforeEach(mountCallback({ template, data }))
beforeEach(() => {
mount({ template, data })
})

it('shows 3 items', () => {
cy.get('li').should('have.length', 3)
Expand Down
2 changes: 1 addition & 1 deletion npm/vue/cypress/component/basic/mixins/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# mixins

You can register global mixin component instances when mounting the a component. See [spec.js](spec.js)
You can register global mixin component instances when mounting the a component. See [spec.cy.js](spec.cy.js)

See [Vue global mixin docs](https://vuejs.org/v2/guide/mixins.html#Global-Mixin)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference types="cypress" />
import { mount, mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'

describe('Mixins', () => {
const template = '<div>mixin test</div>'
Expand All @@ -17,13 +17,13 @@ describe('Mixins', () => {
mixin,
}

beforeEach(mountCallback({ template }, { extensions }))

it('calls mixin "created" method', () => {
// the "created" will be called twice
// 1 - when the test wrapper element made by the Vue test utils is created
// 2 - when the element above we are testing is created
expect(MyMixin.created).to.have.been.calledTwice
mount({ template }, { extensions }).then(() => {
// the "created" will be called twice
// 1 - when the test wrapper element made by the Vue test utils is created
// 2 - when the element above we are testing is created
expect(MyMixin.created).to.have.been.calledTwice
})
})
})

Expand Down
9 changes: 6 additions & 3 deletions npm/vue/cypress/component/basic/options.cy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'

const template = `
<div id="app">
{{ message }}
</div>
`

describe('Mount component', () => {
// TODO: fix with https://github.com/cypress-io/cypress/issues/30706
describe.skip('Mount component', () => {
// hmm, there are no more options to pass

const component = {
Expand All @@ -18,7 +19,9 @@ describe('Mount component', () => {
},
}

beforeEach(mountCallback(component))
beforeEach(() => {
mount(component)
})

it('shows hello', () => {
cy.contains('Hello Vue!')
Expand Down
7 changes: 4 additions & 3 deletions npm/vue/cypress/component/basic/plugins/plugin.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="cypress" />
import { MyPlugin } from './MyPlugin'
import { MyPluginWithOptions } from './MyPluginWithOptions'
import { mount, mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'

const EmptyComponent = { template: '<div></div>' }

Expand All @@ -28,8 +28,9 @@ describe('Custom plugin MyPlugin', () => {
use,
}

// use "mountCallback" to register the plugins
beforeEach(mountCallback(EmptyComponent, { extensions }))
beforeEach(() => {
mount(EmptyComponent, { extensions })
})

it('registers global method on Vue instance', () => {
cy.wrap(Cypress).its('vue').its('aPluginMethod').should('be.a', 'function')
Expand Down
36 changes: 22 additions & 14 deletions npm/vue/cypress/component/basic/props/message-list.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />
import MessageList from '../MessageList.vue'
import { mount, mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'

// common utils for MessageList
const getItems = () => cy.get('ul li')
Expand All @@ -21,7 +21,9 @@ describe('Props', () => {
})

context('MessageList without props', () => {
beforeEach(mountCallback(MessageList))
beforeEach(() => {
mount(MessageList)
})

it('shows no messages', () => {
getItems().should('not.exist')
Expand All @@ -38,20 +40,23 @@ describe('Props', () => {
})
})

context('MessageList with props', () => {
// TODO: fix with https://github.com/cypress-io/cypress/issues/30706
context.skip('MessageList with props', () => {
const template = `
<div>
<MessageList :messages="messages"/>
</div>
`
<div>
<MessageList :messages="messages"/>
</div>
`

const data = () => ({ messages: ['uno', 'dos'] })

const components = {
MessageList,
}

beforeEach(mountCallback({ template, data, components }))
beforeEach(() => {
mount({ template, data, components })
})

it('shows two items at the start', () => {
getItems().should('have.length', 2)
Expand All @@ -60,24 +65,27 @@ describe('Props', () => {

context('MessageList under message-list name', () => {
const template = `
<div>
<message-list :messages="messages"/>
</div>
`
<div>
<message-list :messages="messages"/>
</div>
`

const data = () => ({ messages: ['uno', 'dos'] })

const components = {
'message-list': MessageList,
}

beforeEach(mountCallback({ template, data, components }))
beforeEach(() => {
mount({ template, data, components })
})

it('starts with two items', () => {
expect(Cypress.vue.messages).to.deep.equal(['uno', 'dos'])
})

it('shows two items at the start', () => {
// TODO: fix with https://github.com/cypress-io/cypress/issues/30706
it.skip('shows two items at the start', () => {
getItems().should('have.length', 2)
})
})
Expand Down
10 changes: 6 additions & 4 deletions npm/vue/cypress/component/basic/reverse.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'

/* eslint-env mocha */
describe('Handling User Input', () => {
// TODO: fix with https://github.com/cypress-io/cypress/issues/30706
describe.skip('Handling User Input', () => {
// Example from https://vuejs.org/v2/guide/#Handling-User-Input
const template = `
<div>
Expand All @@ -20,7 +20,9 @@ describe('Handling User Input', () => {
},
}

beforeEach(mountCallback({ template, data, methods }))
beforeEach(() => {
mount({ template, data, methods })
})

it('reverses text', () => {
cy.contains('Hello Vue')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'

/* eslint-env mocha */
describe('Declarative rendering', () => {
// TODO: fix with https://github.com/cypress-io/cypress/issues/30706
describe.skip('Declarative rendering', () => {
// Vue code from https://vuejs.org/v2/guide/#Declarative-Rendering
const template = `
<div id="app">
{{ message }}
</div>
`

beforeEach(
mountCallback({
beforeEach(() => {
mount({
template,
data () {
return { message: 'Hello Vue!' }
},
}),
)
})
})

it('shows hello', () => {
cy.contains('Hello Vue!')
Expand Down
4 changes: 4 additions & 0 deletions npm/vue/cypress/component/basic/style-in-spec/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.todo.done {
text-decoration: line-through;
color: gray;
}
Loading

0 comments on commit 5cf6026

Please sign in to comment.