Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Apr 11, 2019
1 parent a5512f1 commit d8412fb
Show file tree
Hide file tree
Showing 8 changed files with 1,026 additions and 79 deletions.
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
],
"env": {
"test": {
"presets": [
[
"@babel/env", {
"targets": { "node": "current" }
}
],
],
"plugins": [
"@babel/plugin-syntax-dynamic-import"
]
Expand Down
37 changes: 37 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require('path')

module.exports = {
rootDir: path.resolve(__dirname),
roots: [
'<rootDir>/src',
],
moduleFileExtensions: [
'js',
'jsx',
'json',
'vue',
],
transform: {
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.jsx?$': 'babel-jest',
},
transformIgnorePatterns: [
'/node_modules/',
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
snapshotSerializers: [
'jest-serializer-vue',
],
// testMatch: [
// '**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)',
// ],
testURL: 'http://localhost/',
collectCoverage: true,
collectCoverageFrom: ['**/*.{js,jsx,vue}'],
setupFiles: [
'<rootDir>/tests/unit/jest-setup',
],
}
48 changes: 25 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,22 @@
"name": "v-tooltip",
"version": "2.0.0-rc.33",
"description": "Easy tooltips with Vue 2.x",
"main": "dist/v-tooltip.umd.js",
"module": "dist/v-tooltip.esm.js",
"unpkg": "dist/v-tooltip.min.js",
"author": "Guillaume Chau <[email protected]>",
"scripts": {
"build": "NODE_ENV=production npm run build:browser && npm run build:es && npm run build:umd",
"test": "npm run test:unit",
"build:browser": "rollup --config build/rollup.config.browser.js",
"build:es": "rollup --config build/rollup.config.es.js",
"build:umd": "rollup --config build/rollup.config.umd.js",
"prepublishOnly": "npm run test && npm run build",
"dev": "cross-env NODE_ENV=development rollup --config build/rollup.config.es.js --watch",
"test": "npm run test:unit",
"test:unit": "jest --config tests/unit/jest.config.js --coverage",
"demo:build": "vue-cli-service build",
"demo:serve": "vue-cli-service serve",
"demo:build": "vue-cli-service build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Akryum/vue-tooltip.git"
},
"keywords": [
"vue",
"tooltip"
],
"author": "Guillaume Chau <[email protected]>",
"license": "ISC",
"bugs": {
"url": "https://github.com/Akryum/vue-tooltip/issues"
"dev": "cross-env NODE_ENV=development rollup --config build/rollup.config.es.js --watch",
"prepublishOnly": "npm run test && npm run build",
"test:unit": "vue-cli-service test:unit"
},
"homepage": "https://github.com/Akryum/vue-tooltip#readme",
"main": "dist/v-tooltip.umd.js",
"module": "dist/v-tooltip.esm.js",
"unpkg": "dist/v-tooltip.min.js",
"dependencies": {
"lodash.merge": "^4.6.1",
"popper.js": "^1.15.0",
Expand All @@ -45,8 +32,10 @@
"@babel/preset-env": "^7.4.2",
"@vue/cli-plugin-babel": "^3.5.1",
"@vue/cli-plugin-eslint": "^3.5.1",
"@vue/cli-plugin-unit-jest": "^3.5.3",
"@vue/cli-service": "^3.5.1",
"@vue/test-utils": "^1.0.0-beta.29",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.7.1",
"clean-css": "^4.1.8",
Expand Down Expand Up @@ -82,5 +71,18 @@
"browserslist": [
"> 1%",
"last 2 versions"
]
],
"bugs": {
"url": "https://github.com/Akryum/vue-tooltip/issues"
},
"homepage": "https://github.com/Akryum/vue-tooltip#readme",
"keywords": [
"vue",
"tooltip"
],
"license": "ISC",
"repository": {
"type": "git",
"url": "git+https://github.com/Akryum/vue-tooltip.git"
}
}
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function addClasses (el, classes) {
classList.push(newClass)
}
})
if (el instanceof SVGElement) {
if (el.prototype && el instanceof SVGElement) {
el.setAttribute('class', classList.join(' '))
} else {
el.className = classList.join(' ')
Expand Down Expand Up @@ -58,7 +58,7 @@ export function removeClasses (el, classes) {
classList.splice(index, 1)
}
})
if (el instanceof SVGElement) {
if (el.prototype && el instanceof SVGElement) {
el.setAttribute('class', classList.join(' '))
} else {
el.className = classList.join(' ')
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
env: {
jest: true
}
}
2 changes: 1 addition & 1 deletion tests/unit/jest-setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'babel-polyfill'
import '@babel/polyfill'

global.SVGAnimatedString = () => {}
global.SVGElement = () => {}
30 changes: 0 additions & 30 deletions tests/unit/jest.config.js

This file was deleted.

Loading

0 comments on commit d8412fb

Please sign in to comment.