-
-
Save lazyTai/9658fae25fd0692346f12b63814b0e99 to your computer and use it in GitHub Desktop.
karam test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*actually i dont want to leanr the shit chai 没办法*/ | |
import chai from 'chai' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
] | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
] | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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