This repository was archived by the owner on Dec 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Use Vue Test Utils to manage options like scoped slots and option normalizaiton #365
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
147d74d
Use Vue Test Utils to manage options like scoped slots and option nor…
JessicaSachs ca107c3
using createLocalVue to ensure global Vue namespace doesn't bleed over
JessicaSachs c3e84ed
fix: spec was demonstrating using data as an object, which is a bug i…
JessicaSachs 8cb069d
chore: cleaning up spec
JessicaSachs 87ea052
fix: data should be a function, i18n plugin was throwing error
JessicaSachs f1115e8
fix: plugins not passing options through. i18n spec artifically slow
JessicaSachs eb40fc4
Update src/index.ts
JessicaSachs 85b5175
fix: ...localVue => localVue
JessicaSachs ca2991b
Merge branch 'jess/root-vue-node' of github.com:bahmutov/cypress-vue-…
JessicaSachs e96281c
update mixins test
bahmutov 73f5ee7
enable slot AppInput spec
bahmutov 3c919ca
add full slots and scopedSlots test
bahmutov b93c7c9
Update src/index.ts
JessicaSachs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,17 @@ const template = ` | |
</div> | ||
` | ||
|
||
const data = { | ||
message: 'Hello Vue!', | ||
} | ||
|
||
describe('Mount component', () => { | ||
// hmm, there are no more options to pass | ||
|
||
const component = { template, data } | ||
const component = { | ||
template, | ||
data() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so during the test, what if we check the |
||
return { | ||
message: 'Hello Vue!', | ||
} | ||
}, | ||
} | ||
beforeEach(mountCallback(component)) | ||
|
||
it('shows hello', () => { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// In this test file we demo how to test a component with slots and a scoped slot. | ||
|
||
// Usage is the same as Vue Test Utils, since slots and scopedSlots | ||
// in the render options are directly passed through to the Utils mount(). | ||
|
||
/// <reference types="cypress" /> | ||
|
||
import Card from './Card.vue' | ||
import { mount } from 'cypress-vue-unit-test' | ||
|
||
describe('Card', () => { | ||
it('skipped slots', () => { | ||
mount(Card) | ||
cy.contains('Nothing used the Scoped content!').should('be.visible') | ||
}) | ||
|
||
it('renders slots', () => { | ||
mount(Card, { | ||
slots: { | ||
header: '<h1>HEADER</h1>', | ||
footer: '<div>FOOTER</div>', | ||
}, | ||
}) | ||
cy.contains('h1', 'HEADER') | ||
cy.contains('div', 'FOOTER') | ||
}) | ||
|
||
it('renders scopedSlots', () => { | ||
mount(Card, { | ||
scopedSlots: { | ||
default: '<p>Yay! {{props.content}}</p>', | ||
}, | ||
}) | ||
cy.contains('Yay! Scoped content!').should('be.visible') | ||
cy.contains('Nothing used the Scoped content!').should('not.exist') | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<template> | ||
<div class="card"> | ||
<slot name="header" /> | ||
<slot :content="content"> | ||
<!-- Fallback content if no default slot is given --> | ||
<p>Nothing used the {{ content }}</p> | ||
</slot> | ||
<slot name="footer" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
// example from https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/components/Card.vue | ||
// For the sake of demoing scopedSlots, this Card component | ||
// passes a simple string down to its default slot. | ||
export default { | ||
data() { | ||
return { | ||
content: 'Scoped content!' | ||
} | ||
} | ||
} | ||
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Slots | ||
|
||
Testing [Vue slots and scopedSlots](https://vue-test-utils.vuejs.org/api/options.html#slots). | ||
The example taken from [Vue testing library](https://github.com/testing-library/vue-testing-library) | ||
|
||
See [Card.vue](Card.vue) and [Card.spec.js](Card.spec.js) | ||
|
||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a feature we should offer because it pollutes Vue state