Skip to content

Instantly share code, notes, and snippets.

Vitaliy Potapov vitalets

Block or report user

Report or block vitalets

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fp.js
// filter array by value
1. f(2, [1, 2, 3, 2]) // -> [2, 2]
2. f([1, 2, 3, 2], 2) // -> [2, 2]
@vitalets
vitalets / sum.js
Last active Dec 8, 2017
Incorrect sum
View sum.js
export default function sum(a, b) {
return a * b; // a bug
}
View sum.test.js
describe('sum', function () {
it('should return sum of arguments', function () {
chai.expect(sum(1, 2)).to.equal(3);
});
});
@vitalets
vitalets / webpack.config.js
Last active Dec 8, 2017
Mocha ES6 modules: webpack config final
View webpack.config.js
module.exports = {
entry: ['./setup.js', './run.js'],
output: {
filename: 'bundle.js',
},
resolve: {
alias: {
// map remote chai.js url to locally installed in node_modules
'https://unpkg.com/chai@4.1.2/chai.js': 'chai/chai.js'
}
@vitalets
vitalets / webpack.config.js
Created Dec 6, 2017
Mocha ES6 modules: webpack config v2
View webpack.config.js
module.exports = {
entry: ['./setup.js', './run.js'],
output: {
filename: 'bundle.js',
},
resolve: {
alias: {
'https://unpkg.com/chai@4.1.2/chai.js': 'chai/chai.js'
}
}
@vitalets
vitalets / index.html
Created Dec 6, 2017
Mocha ES6 modules: index.html with fallback
View index.html
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link href="https://unpkg.com/mocha@4.0.1/mocha.css" rel="stylesheet" />
<script src="https://unpkg.com/mocha@4.0.1/mocha.js"></script>
</head>
<body>
<div id="mocha"></div>
<script type="module" src="setup.js"></script>
@vitalets
vitalets / webpack.config.js
Created Dec 6, 2017
Mocha ES6 modules: webpack config v1
View webpack.config.js
module.exports = {
entry: ['./setup.js', './run.js'],
output: {
filename: 'bundle.js',
}
};
@vitalets
vitalets / index.html
Created Dec 5, 2017
Mocha ES6 Modules
View index.html
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link href="https://unpkg.com/mocha@4.0.1/mocha.css" rel="stylesheet" />
<script src="https://unpkg.com/mocha@4.0.1/mocha.js"></script>
</head>
<body>
<div id="mocha"></div>
<script type="module" src="setup.js"></script>
@vitalets
vitalets / run.js
Last active Dec 5, 2017
Mocha ES6 modules: correct run.js
View run.js
import './sum.test.js';
mocha.checkLeaks();
mocha.run();
View setup.js
import 'https://unpkg.com/chai@4.1.2/chai.js';
mocha.setup('bdd');
You can’t perform that action at this time.