Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-jest

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-jest - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

lib/load-babel-config.js

30

CHANGELOG.md

@@ -0,1 +1,31 @@

<a name="v1.4.1"></a>
## [v1.4.1](https://github.com/eddyerburgh/vue-jest/compare/v1.3.0...v1.4.1) (2017-12-13)
### Bug Fixes
* replace coffee-script with coffeescript ([#34](https://github.com/eddyerburgh/vue-jest/issues/34)) ([2ec4144](https://github.com/eddyerburgh/vue-jest/commit/2ec4144))
### Features
* transpile coffeescript written in ES6 ([#35](https://github.com/eddyerburgh/vue-jest/issues/35)) ([c5448c7](https://github.com/eddyerburgh/vue-jest/commit/c5448c7))
* **sourceMap:** Add source mapping for external scripts ([#37](https://github.com/eddyerburgh/vue-jest/issues/37)) ([213ac68](https://github.com/eddyerburgh/vue-jest/commit/213ac68))
<a name="v1.4.0"></a>
# [v1.4.0](https://github.com/eddyerburgh/vue-jest/compare/v1.3.0...v1.4.0) (2017-12-13)
### Bug Fixes
* replace coffee-script with coffeescript ([#34](https://github.com/eddyerburgh/vue-jest/issues/34)) ([2ec4144](https://github.com/eddyerburgh/vue-jest/commit/2ec4144))
### Features
* transpile coffeescript written in ES6 ([#35](https://github.com/eddyerburgh/vue-jest/issues/35)) ([c5448c7](https://github.com/eddyerburgh/vue-jest/commit/c5448c7))
<a name="v1.3.0"></a>

@@ -2,0 +32,0 @@ # [v1.3.0](https://github.com/eddyerburgh/vue-jest/compare/v1.2.0...v1.3.0) (2017-12-05)

27

lib/compilers/babel-compiler.js
const babel = require('babel-core')
const findBabelConfig = require('find-babel-config')
const logger = require('../logger')
const cache = require('../cache')
const loadBabelConfig = require('../load-babel-config.js')
var defaultBabelOptions = {
presets: [require.resolve('babel-preset-vue-app')]
}
function getBabelConfig () {
const cachedConfig = cache.get('babel-config')
if (cachedConfig) {
return cachedConfig
} else {
const { file, config } = findBabelConfig.sync(process.cwd(), 0)
if (!file) {
logger.info('no .babelrc found, defaulting to default babel options')
}
const babelConfig = file ? config : defaultBabelOptions
cache.set('babel-config', babelConfig)
return babelConfig
}
}
module.exports = function compileBabel (scriptContent, inputSourceMap) {

@@ -31,6 +10,4 @@ const sourceMapOptions = {

const babelConfig = getBabelConfig()
const babelOptions = Object.assign(sourceMapOptions, loadBabelConfig())
const babelOptions = Object.assign(sourceMapOptions, babelConfig)
const res = babel.transform(scriptContent, babelOptions)

@@ -37,0 +14,0 @@

var ensureRequire = require('../ensure-require.js')
const throwError = require('../throw-error')
const loadBabelConfig = require('../load-babel-config.js')
module.exports = function (raw, cb, compiler) {
ensureRequire('coffee', ['coffee-script'])
var coffee = require('coffee-script')
ensureRequire('coffee', ['coffeescript'])
var coffee = require('coffeescript')
var compiled

@@ -11,3 +12,4 @@ try {

bare: true,
sourceMap: true
sourceMap: true,
transpile: loadBabelConfig()
})

@@ -14,0 +16,0 @@ } catch (err) {

@@ -53,3 +53,8 @@ const vueCompiler = require('vue-template-compiler')

const map = generateSourceMap(script, '', path, src, inputMap)
let scriptSrc = src
if (parts.script && parts.script.src) {
scriptSrc = parts.script.content
}
const map = generateSourceMap(script, '', path, scriptSrc, inputMap)
let output = ';(function(){\n' + script + '\n})()\n' +

@@ -56,0 +61,0 @@ 'if (module.exports.__esModule) module.exports = module.exports.default\n' +

{
"name": "vue-jest",
"version": "1.3.0",
"version": "1.4.0",
"description": "Jest Vue transform",

@@ -32,3 +32,3 @@ "main": "vue-jest.js",

"clear-module": "^2.1.0",
"coffee-script": "^1.12.7",
"coffeescript": "^2.0.3",
"conventional-changelog": "^1.1.5",

@@ -35,0 +35,0 @@ "eslint": "^4.3.0",

@@ -107,1 +107,8 @@ import Vue from 'vue'

})
test('generates inline sourcemap for .vue files using src attributes', () => {
const filePath = resolve(__dirname, './resources/BasicSrc.vue')
const fileString = readFileSync(filePath, { encoding: 'utf8' })
const output = jestVue.process(fileString, filePath)
expect(output.map).toMatchSnapshot()
})

@@ -1,11 +0,94 @@

import { shallow } from 'vue-test-utils'
import { shallow, mount } from 'vue-test-utils'
import Coffee from './resources/Coffee.vue'
import CoffeeScript from './resources/CoffeeScript.vue'
import CoffeeES6 from './resources/CoffeeES6.vue'
import CoffeeScriptES6 from './resources/CoffeeScriptES6.vue'
import jestVue from '../vue-jest'
import { resolve } from 'path'
import {
readFileSync,
writeFileSync,
renameSync
} from 'fs'
import clearModule from 'clear-module'
import cache from '../lib/cache'
test('processes .vue file with lang set to coffeescript', () => {
shallow(Coffee)
})
describe('Test CoffeeScript - coffee.spec.js', () => {
beforeEach(() => {
cache.flushAll()
clearModule.all()
})
test('processes .vue file with lang set to coffeescript', () => {
shallow(CoffeeScript)
test('processes .vue file with lang set to coffee', () => {
shallow(Coffee)
})
test('processes .vue file with lang set to coffeescript', () => {
shallow(CoffeeScript)
})
test('processes .vue file with lang set to coffee (ES6)', () => {
shallow(CoffeeES6)
})
test('processes .vue file with lang set to coffeescript (ES6)', () => {
shallow(CoffeeScriptES6)
})
test('processes .vue file with lang set to coffeescript (ES6)', () => {
const wrapper = mount(CoffeeScriptES6)
expect(typeof wrapper).toBe('object')
})
test('processes .vue files with lang set to coffeescript using .babelrc if there is no .babelrc', () => {
const babelRcPath = resolve(__dirname, '../.babelrc')
const tempPath = resolve(__dirname, '../.renamed')
renameSync(babelRcPath, tempPath)
const filePath = resolve(__dirname, './resources/CoffeeScriptES6.vue')
const fileString = readFileSync(filePath, { encoding: 'utf8' })
try {
jestVue.process(fileString, filePath)
} catch (err) {
renameSync(tempPath, babelRcPath)
throw err
}
renameSync(tempPath, babelRcPath)
})
test('processes .vue files with lang set to coffeescript, uses babelrc in package.json if none in .babelrc', () => {
const babelRcPath = resolve(__dirname, '../.babelrc')
const tempPath = resolve(__dirname, '../.renamed')
const packagePath = resolve(__dirname, '../package.json')
const packageOriginal = readFileSync(packagePath, { encoding: 'utf8' })
writeFileSync(packagePath, '{ "babel": {"presets": ["env"],"plugins": ["istanbul"]}}')
renameSync(babelRcPath, tempPath)
const filePath = resolve(__dirname, './resources/CoffeeScriptES6.vue')
const fileString = readFileSync(filePath, { encoding: 'utf8' })
try {
const output = jestVue.process(fileString, filePath)
expect(output.code).toContain('coverageData.hash')
} catch (err) {
renameSync(tempPath, babelRcPath)
writeFileSync(packagePath, packageOriginal)
jest.resetModules()
throw err
}
renameSync(tempPath, babelRcPath)
writeFileSync(packagePath, packageOriginal)
jest.resetModules()
})
test('processes .vue files with lang set to coffeescript using .babelrc if it exists in route', () => {
const babelRcPath = resolve(__dirname, '../.babelrc')
const babelRcOriginal = readFileSync(babelRcPath, { encoding: 'utf8' })
writeFileSync(babelRcPath, '{"presets": ["env"],"plugins": ["istanbul"]}')
const filePath = resolve(__dirname, './resources/CoffeeScriptES6.vue')
const fileString = readFileSync(filePath, { encoding: 'utf8' })
const output = jestVue.process(fileString, filePath)
writeFileSync(babelRcPath, babelRcOriginal)
// coverageData.hash is added by babel-plugin-istanbul, added to root .babelrc for this test only
expect(output.code).toContain('coverageData.hash')
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc