Skip to content

#27 - Provide cleanup-after-each #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
coverage
npm
dist
.opt-in
.opt-out
.DS_Store
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ npm install --save-dev vue-testing-library
## Usage

```
npm install --save-dev vue-testing-library
npm install --save-dev @testing-library/vue
jest
vue-jest
babel-jest
Expand Down Expand Up @@ -99,7 +99,7 @@ npm install --save-dev vue-testing-library

// src/TestComponent.spec.js
import 'jest-dom/extend-expect'
import { render } from 'vue-testing-library'
import { render } from '@testing-library/vue'
import TestComponent from './TestComponent'

test('should render HelloWorld', () => {
Expand Down
1 change: 1 addition & 0 deletions cleanup-after-each.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
afterEach(require('./dist').cleanup)
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ module.exports = {
'js',
'vue'
],
moduleNameMapper: {
'@testing-library/vue': '<rootDir>/src/vue-testing-library.js'
},
coverageDirectory: './coverage',
collectCoverageFrom: [
'**/src/**/*.js',
Expand All @@ -15,7 +18,7 @@ module.exports = {
],
testPathIgnorePatterns: [
'/node_modules/',
'<rootDir>/npm/',
'<rootDir>/dist/',
'<rootDir>/tests/__tests__/components/'
],
transform: {
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
"name": "@testing-library/vue",
"version": "1.0.0",
"description": "Simple and complete Vue DOM testing utilities that encourage good testing practices.",
"main": "npm/vue-testing-library.js",
"main": "dist/vue-testing-library.js",
"scripts": {
"lint": "eslint --ext .js,.vue .",
"lint:fix": "eslint --ext .js,.vue . --fix",
"test": "jest --coverage",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
"version": "babel src --out-dir npm"
"prepublishOnly": "babel src --out-dir dist"
},
"files": [
"npm"
"dist",
"cleanup-after-each.js"
],
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/debug.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import HelloWorld from './components/HelloWorld'
import { cleanup, render } from 'vue-testing-library'
import { cleanup, render } from '@testing-library/vue'

beforeEach(() => {
jest.spyOn(console, 'log').mockImplementation(() => {})
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/end-to-end.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, wait } from 'vue-testing-library'
import { render, wait } from '@testing-library/vue'
import EndToEnd from './components/EndToEnd'

test('it waits for the data to be loaded', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/fetch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axiosMock from 'axios'
import { render, fireEvent } from 'vue-testing-library'
import { render, fireEvent } from '@testing-library/vue'
import Fetch from './components/Fetch.vue'
import 'jest-dom/extend-expect'

Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, fireEvent } from 'vue-testing-library'
import { render, fireEvent } from '@testing-library/vue'
import Login from './components/Login'

test('login form submits', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/integration-with-stubs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, cleanup } from 'vue-testing-library'
import { render, cleanup } from '@testing-library/vue'
import Form from './components/Form'

afterEach(cleanup)
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/number-display.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NumberDisplay from './components/NumberDisplay.vue'
import { render } from 'vue-testing-library'
import { render } from '@testing-library/vue'
import 'jest-dom/extend-expect'

test('calling render with the same component but different props does not remount', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/router/programmatic-routing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import App from './components/App.vue'
import Home from './components/Home.vue'
import About from './components/About.vue'

import { render, fireEvent } from 'vue-testing-library'
import { render, fireEvent } from '@testing-library/vue'

const routes = [
{ path: '/', component: Home },
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/simple-button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, cleanup, fireEvent } from 'vue-testing-library'
import { render, cleanup, fireEvent } from '@testing-library/vue'
import SimpleButton from './components/Button'

afterEach(cleanup)
Expand Down
4 changes: 3 additions & 1 deletion tests/__tests__/stopwatch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import StopWatch from './components/StopWatch.vue'
import { render, wait, fireEvent } from 'vue-testing-library'
import { cleanup, render, wait, fireEvent } from '@testing-library/vue'
import 'jest-dom/extend-expect'

afterEach(cleanup)

test('unmounts a component', async () => {
jest.spyOn(console, 'error').mockImplementation(() => {})

Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/validate-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import VeeValidate from 'vee-validate'
import 'jest-dom/extend-expect'

import { render, fireEvent } from 'vue-testing-library'
import { render, fireEvent } from '@testing-library/vue'
import Validate from './components/Validate'

test('can validate using plugin', async () => {
Expand Down
4 changes: 3 additions & 1 deletion tests/__tests__/vue-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import App from './components/Router/App.vue'
import Home from './components/Router/Home.vue'
import About from './components/Router/About.vue'

import { render, fireEvent } from 'vue-testing-library'
import { cleanup, render, fireEvent } from '@testing-library/vue'

const routes = [
{ path: '/', component: Home },
{ path: '/about', component: About },
{ path: '*', redirect: '/about' }
]

afterEach(cleanup)

test('full app rendering/navigating', async () => {
const { queryByTestId } = render(App, { routes })

Expand Down
4 changes: 3 additions & 1 deletion tests/__tests__/vuex.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'jest-dom/extend-expect'

import VuexTest from './components/VuexTest'
import { render, fireEvent } from 'vue-testing-library'
import { cleanup, render, fireEvent } from '@testing-library/vue'

afterEach(cleanup)

const store = {
state: {
Expand Down