Skip to content

Instantly share code, notes, and snippets.

@zemlanin
Created September 2, 2016 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zemlanin/608c7e636c48c1e6064d7fd1efa13816 to your computer and use it in GitHub Desktop.
Save zemlanin/608c7e636c48c1e6064d7fd1efa13816 to your computer and use it in GitHub Desktop.
wallaby transform
{
"presets": ["es2015", "react"]
}
node_modules
index-ts.js
import React from 'react'
const JSX = () => <div />
export default JSX
import * as React from 'react'
const TSX = () => <div />
export default TSX
{
"name": "wallaby-transform",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"@types/react": "^0.14.33",
"babel-core": "^6.14.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"mocha": "^3.0.2",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"typescript": "^2.0.2",
"wallaby-webpack": "^0.0.23"
},
"devDependencies": {},
"scripts": {
"build": "tsc && babel index-js.jsx index-ts.js",
"test": "tsc && mocha test.js --compilers js:babel-core/register"
},
"keywords": [],
"author": "",
"license": "ISC"
}
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import assert from 'assert'
import JSX from './index-js'
import TSX from './index-ts'
describe('JSX', () => {
it('should have correct component name', () => {
assert.equal(JSX.name, 'JSX')
})
})
describe('TSX', () => {
it('should have correct component name', () => {
assert.equal(TSX.name, 'TSX')
})
})
{
"compilerOptions": {
"target": "es5",
"jsx": "react",
"module": "commonjs"
}
}
module.exports = function (wallaby) {
// comment next line to break component names
wallaby.defaults.files.instrument = false
return {
files: [
'./index*.jsx',
'./index*.tsx',
],
tests: [
'./test.js'
],
compilers: {
'**/*.js*': wallaby.compilers.babel({ babelrc: true }),
'**/*.ts*': wallaby.compilers.typeScript(),
},
preprocessors: {
'**/*.js*': (file) => require('babel-core').transform(file.content, {
"presets": ["es2015", "react"]
})
},
testFramework: 'mocha',
env: {
type: 'node'
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment