Skip to content

Instantly share code, notes, and snippets.

@lazyTai
Last active September 27, 2017 03:40
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 lazyTai/9658fae25fd0692346f12b63814b0e99 to your computer and use it in GitHub Desktop.
Save lazyTai/9658fae25fd0692346f12b63814b0e99 to your computer and use it in GitHub Desktop.
karam test
/*actually i dont want to leanr the shit chai 没办法*/
import chai from 'chai'
var webpack=require('webpack')
/*
1.how to debuge this shit
1.run karma start
2.click debug
3.f12
4.denugger in you js
*/
module.exports=function(config){
config.set({
basePath:'./',
frameworks:['mocha'],
/*...*/
files:[
'test/*.js'
],
browsers:['Chrome'],
preprocessors: {
'test/*.js': ['webpack'],
},
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
debug:true,
webpack: {
module: {
loaders:[
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react','flow'],
cacheDirectory: true
},
exclude: /(node_modules|bower_components)/,
}
]
}
},
webpackMiddleware: {
stats: {
colors: true
}
},
colors:true,
autoWatch: true,
plugins: [
require('karma-mocha'),
require('karma-spec-reporter'),
require('karma-chrome-launcher'),
require('karma-webpack')
]
})
}
//@flow
import React from 'react'
type Props={
foo:number,
bar?:string
}
class Com extends React.Component<Props>{
_click(){
debugger
}
render(){
debugger
return <div >
{this.props.foo}
</div>
}
}
export default Com
var assert = require('assert');
describe('Array', function() {
it("index of",function(){
assert.equal(-1,[1,2,3].indexOf(4))
})
var asynfunction =function(done){
setTimeout(function(){
done()
return "hello asynfunction"
},1000)
}
it('asyn code',function(done){
asynfunction(done)
})
before(function(){
console.log("before")
})
after(function(){
console.log("after")
})
});
var webpack=require('webpack')
/*
1.how to debuge this shit
1.run karma start
2.click debug
3.f12
4.denugger in you js
*/
module.exports=function(config){
config.set({
basePath:'./',
frameworks:['mocha'],
/*...*/
files:[
'test/index.test.js',
'test/*.js'
],
browsers:['Chrome'],
preprocessors: {
'test/*': ['webpack']
},
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
debug:true,
webpack: {
module: {}
},
webpackMiddleware: {
stats: {
colors: true
}
},
colors:true,
autoWatch: true,
plugins: [
require('karma-mocha'),
require('karma-spec-reporter'),
require('karma-chrome-launcher'),
require('karma-webpack')
]
})
}
var assert = require('assert');
describe('Array', function() {
it("index of",function(){
assert.equal(-1,[1,2,3].indexOf(4))
})
var asynfunction =function(done){
setTimeout(function(){
done()
return "hello asynfunction"
},1000)
}
it('asyn code',function(done){
asynfunction(done)
})
});
var assert = require('assert');
describe('Array', function() {
describe.only('array',function(){
it('index of',function(){
assert.equal(-1,[1,2,3].indexOf(4))
})
})
describe.only('asyn',function(){
var asynfunction =function(done){
setTimeout(function(){
done()
return "hello asynfunction"
},1000)
}
it('asyn code',function(done){
asynfunction(done)
})
})
before(function(){
console.log("before")
})
after(function(){
console.log("after")
})
});
import React from 'react'
import assert from 'assert'
import {renderIntoDocument,
Simulate,
findAllInRenderedTree,
findRenderedDOMComponentWithClass
} from 'react-dom/test-utils'; // ES6
import Com from '../src/test/start.jsx'
var expect = require('expect');
describe('root', function () {
it('renders without problems', function () {
var root = renderIntoDocument(<Com/>);
var button=findRenderedDOMComponentWithClass(root,"button")
Simulate.click(button)
expect("")
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment