From d6cbc2a80d018af74eed7d895373b1265c6b9d76 Mon Sep 17 00:00:00 2001 From: Damon Muma Date: Tue, 2 Jul 2019 10:02:42 -0400 Subject: [PATCH 1/2] note babel-bridge in Jest SFC instructions Because of vue-jest's dependency on babel-core (babel 6), if you're using babel 7 your tests will fail. --- docs/guides/testing-single-file-components-with-jest.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guides/testing-single-file-components-with-jest.md b/docs/guides/testing-single-file-components-with-jest.md index 7661d4ad2..2eae1559c 100644 --- a/docs/guides/testing-single-file-components-with-jest.md +++ b/docs/guides/testing-single-file-components-with-jest.md @@ -55,6 +55,8 @@ Next, create a `jest` block in `package.json`: > **Note:** `vue-jest` currently does not support all the features of `vue-loader`, for example custom block support and style loading. In addition, some webpack-specific features such as code-splitting are not supported either. To use these unsupported features, you need to use Mocha instead of Jest to run your tests, and webpack to compile your components. To get started, read the guide on [testing SFCs with Mocha + webpack](./testing-single-file-components-with-mocha-webpack.md). +> **Note:** If you are using Babel 7 or higher, you will need to add [babel-bridge](https://github.com/babel/babel-bridge) to your devDependencies (`$ npm install --save-dev babel-core@^7.0.0-bridge.0`). + ### Handling webpack Aliases If you use a resolve alias in the webpack config, e.g. aliasing `@` to `/src`, you need to add a matching config for Jest as well, using the `moduleNameMapper` option: From ccf0419d4094dfa6a5144ba03e7e03aa8fe6d928 Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Mon, 20 Jan 2020 22:03:27 +1000 Subject: [PATCH 2/2] fix: lint --- packages/test-utils/src/error-wrapper.js | 116 ++++++----------------- 1 file changed, 29 insertions(+), 87 deletions(-) diff --git a/packages/test-utils/src/error-wrapper.js b/packages/test-utils/src/error-wrapper.js index c7da711db..6b65d3d47 100644 --- a/packages/test-utils/src/error-wrapper.js +++ b/packages/test-utils/src/error-wrapper.js @@ -17,41 +17,31 @@ export default class ErrorWrapper implements BaseWrapper { attributes(): void { throwError( - `find did not return ${ - this.selector - }, cannot call attributes() on empty Wrapper` + `find did not return ${this.selector}, cannot call attributes() on empty Wrapper` ) } classes(): void { throwError( - `find did not return ${ - this.selector - }, cannot call classes() on empty Wrapper` + `find did not return ${this.selector}, cannot call classes() on empty Wrapper` ) } contains(): void { throwError( - `find did not return ${ - this.selector - }, cannot call contains() on empty Wrapper` + `find did not return ${this.selector}, cannot call contains() on empty Wrapper` ) } emitted(): void { throwError( - `find did not return ${ - this.selector - }, cannot call emitted() on empty Wrapper` + `find did not return ${this.selector}, cannot call emitted() on empty Wrapper` ) } emittedByOrder(): void { throwError( - `find did not return ${ - this.selector - }, cannot call emittedByOrder() on empty Wrapper` + `find did not return ${this.selector}, cannot call emittedByOrder() on empty Wrapper` ) } @@ -61,73 +51,55 @@ export default class ErrorWrapper implements BaseWrapper { filter(): void { throwError( - `find did not return ${ - this.selector - }, cannot call filter() on empty Wrapper` + `find did not return ${this.selector}, cannot call filter() on empty Wrapper` ) } visible(): void { throwError( - `find did not return ${ - this.selector - }, cannot call visible() on empty Wrapper` + `find did not return ${this.selector}, cannot call visible() on empty Wrapper` ) } hasAttribute(): void { throwError( - `find did not return ${ - this.selector - }, cannot call hasAttribute() on empty Wrapper` + `find did not return ${this.selector}, cannot call hasAttribute() on empty Wrapper` ) } hasClass(): void { throwError( - `find did not return ${ - this.selector - }, cannot call hasClass() on empty Wrapper` + `find did not return ${this.selector}, cannot call hasClass() on empty Wrapper` ) } hasProp(): void { throwError( - `find did not return ${ - this.selector - }, cannot call hasProp() on empty Wrapper` + `find did not return ${this.selector}, cannot call hasProp() on empty Wrapper` ) } hasStyle(): void { throwError( - `find did not return ${ - this.selector - }, cannot call hasStyle() on empty Wrapper` + `find did not return ${this.selector}, cannot call hasStyle() on empty Wrapper` ) } findAll(): void { throwError( - `find did not return ${ - this.selector - }, cannot call findAll() on empty Wrapper` + `find did not return ${this.selector}, cannot call findAll() on empty Wrapper` ) } find(): void { throwError( - `find did not return ${ - this.selector - }, cannot call find() on empty Wrapper` + `find did not return ${this.selector}, cannot call find() on empty Wrapper` ) } html(): void { throwError( - `find did not return ${ - this.selector - }, cannot call html() on empty Wrapper` + `find did not return ${this.selector}, cannot call html() on empty Wrapper` ) } @@ -139,121 +111,91 @@ export default class ErrorWrapper implements BaseWrapper { isEmpty(): void { throwError( - `find did not return ${ - this.selector - }, cannot call isEmpty() on empty Wrapper` + `find did not return ${this.selector}, cannot call isEmpty() on empty Wrapper` ) } isVisible(): void { throwError( - `find did not return ${ - this.selector - }, cannot call isVisible() on empty Wrapper` + `find did not return ${this.selector}, cannot call isVisible() on empty Wrapper` ) } isVueInstance(): void { throwError( - `find did not return ${ - this.selector - }, cannot call isVueInstance() on empty Wrapper` + `find did not return ${this.selector}, cannot call isVueInstance() on empty Wrapper` ) } name(): void { throwError( - `find did not return ${ - this.selector - }, cannot call name() on empty Wrapper` + `find did not return ${this.selector}, cannot call name() on empty Wrapper` ) } props(): void { throwError( - `find did not return ${ - this.selector - }, cannot call props() on empty Wrapper` + `find did not return ${this.selector}, cannot call props() on empty Wrapper` ) } text(): void { throwError( - `find did not return ${ - this.selector - }, cannot call text() on empty Wrapper` + `find did not return ${this.selector}, cannot call text() on empty Wrapper` ) } setComputed(): void { throwError( - `find did not return ${ - this.selector - }, cannot call setComputed() on empty Wrapper` + `find did not return ${this.selector}, cannot call setComputed() on empty Wrapper` ) } setData(): void { throwError( - `find did not return ${ - this.selector - }, cannot call setData() on empty Wrapper` + `find did not return ${this.selector}, cannot call setData() on empty Wrapper` ) } setMethods(): void { throwError( - `find did not return ${ - this.selector - }, cannot call setMethods() on empty Wrapper` + `find did not return ${this.selector}, cannot call setMethods() on empty Wrapper` ) } setProps(): void { throwError( - `find did not return ${ - this.selector - }, cannot call setProps() on empty Wrapper` + `find did not return ${this.selector}, cannot call setProps() on empty Wrapper` ) } setValue(): void { throwError( - `find did not return ${ - this.selector - }, cannot call setValue() on empty Wrapper` + `find did not return ${this.selector}, cannot call setValue() on empty Wrapper` ) } setChecked(): void { throwError( - `find did not return ${ - this.selector - }, cannot call setChecked() on empty Wrapper` + `find did not return ${this.selector}, cannot call setChecked() on empty Wrapper` ) } setSelected(): void { throwError( - `find did not return ${ - this.selector - }, cannot call setSelected() on empty Wrapper` + `find did not return ${this.selector}, cannot call setSelected() on empty Wrapper` ) } trigger(): void { throwError( - `find did not return ${ - this.selector - }, cannot call trigger() on empty Wrapper` + `find did not return ${this.selector}, cannot call trigger() on empty Wrapper` ) } destroy(): void { throwError( - `find did not return ${ - this.selector - }, cannot call destroy() on empty Wrapper` + `find did not return ${this.selector}, cannot call destroy() on empty Wrapper` ) } }