Skip to content

Instantly share code, notes, and snippets.

View gotbahn's full-sized avatar
🐙

Bogdan Plieshka gotbahn

🐙
View GitHub Profile
@gotbahn
gotbahn / CHMQ-0.5.css
Last active August 23, 2016 20:56
Combine & handle Media Queries in Less
.foo {
color: red;
}
.bar {
color: red;
}
@media all and (min-width: 768px) {
.foo {
@gotbahn
gotbahn / .travis.yml
Last active September 10, 2016 14:40
Functional tests with Casper.js in Travis CI
language: node_js
node_js:
- node # latest node.js version
install:
- npm install # can be not specified, runs by default
before_script:
- npm start & # start local server, '&' means use it as parallel process
- sleep 5 # 5s to make sure that local server have enough time to up
script:
- npm test # can be not specified, runs by default
@gotbahn
gotbahn / package.json
Created September 10, 2016 16:08
Functional tests with Casper.js in Travis CI
{
"name": "casper-travis",
"version": "0.0.1",
"description": "Functional tests with Casper.js in Travis CI",
"main": "index.html",
"scripts": {
"preinstall": "npm i -g http-server casperjs",
"start": "http-server",
"test": "casperjs test tests/"
},
@gotbahn
gotbahn / index.html
Last active September 10, 2016 16:20
Functional tests with Casper.js in Travis CI
<button class="action" type="button">Click me</button>
@gotbahn
gotbahn / index.js
Last active September 10, 2016 16:12
Functional tests with Casper.js in Travis CI
document.querySelector('.action').addEventListener('click', function () {
this.insertAdjacentHTML('afterend', '<div class="text">You hear \'click\'</div>');
});
@gotbahn
gotbahn / index-func.js
Created September 10, 2016 16:15
Functional tests with Casper.js in Travis CI
casper.test.begin('Testing index page', 1, function (test) {
casper
.start('http://localhost:8080')
.then(function () {
this.echo('Text appearing', 'COMMENT');
this.click('.action');
test.assertExists('.text', 'Text is appearing after click');
})
.run(function () {
test.done()
@gotbahn
gotbahn / webpack.config.js
Last active January 12, 2021 21:05
0.0 Loading dynamic images with Webpack
{
test: /\.(jpg|png|svg)$/,
type: 'asset/resource',
include: './path/to/images'
}
@gotbahn
gotbahn / index.js
Last active September 15, 2016 11:01
0.1 Loading dynamic images with Webpack
const pathToCat = require('./path/to/cats/grumpy-cat.png');
const getCat = () => `<img src='${pathToCat}' alt='Grumpy Cat' />`;
@gotbahn
gotbahn / index.jsx
Last active September 15, 2016 10:57
0.2 Loading dynamic images with Webpack
const cats = [
'black-cat.png',
'white-cat.png',
'grumpy-cat.png',
'rainbow-cat.png'
];
const getCats = () => cats.map(name => `<img src='./path/to/cats/${name}' alt='${name}' />`);
@gotbahn
gotbahn / index.js
Last active December 12, 2019 11:27
0.3. Loading static and dynamic images with Webpack
const pathToCats = require.context('./path/to/cats', true);
// true here is for use subdirectories, you can also specify regex as third param
const cats = [
'black-cat.png',
'white-cat.png',
'grumpy-cat.png',
'rainbow-cat.png'
];