Skip to content

Instantly share code, notes, and snippets.

View NiGhTTraX's full-sized avatar
🌶️

Andrei Picus NiGhTTraX

🌶️
View GitHub Profile
function Todo(props) {
const { Delete, name, onDelete } = props;
return <div>
<span>{name}</span>
<Delete onSubmit={onDelete}>Delete</Delete>
</div>;
}
function inject(deps, Component) {
return class Injector extends React.Component {
render() {
return <Component {...deps} {...this.props} />;
}
};
}
const SafeTodo = inject(Todo, { DeleteTodo: ConfirmButton });
render(<TodoList Todo={SafeTodo} />);
class ButtonWithConfirm extends Component {
constructor(props) {
super(props);
this.state = { confirming: false };
}
render() {
if (this.state.confirming) {
return <div>
@NiGhTTraX
NiGhTTraX / test.spec.ts
Last active June 19, 2019 10:25
Simple example of a browser test using Mocha, Chai and WebdriverIO
import { remote } from 'webdriverio';
import { expect } from 'chai';
import { describe, it, before, after } from 'mocha';
describe('Mugshot README', () => {
/* BROWSER SETUP */
let browser!: ReturnType<typeof remote>;
before(async () => {
const options = {
@NiGhTTraX
NiGhTTraX / mugshot.spec.ts
Last active June 19, 2019 10:25
Visual test with Mugshot
import Mugshot from 'mugshot';
import WebdriverIOAdapter from '@mugshot/webdriverio';
describe('Mugshot README', () => {
/* BROWSER SETUP */
/* Identical setup from previous example omitted.
/* ENDBROWSER SETUP */
it('should have a logo', async () => {
await browser.url('https://github.com/NiGhTTraX/mugshot/blob/master/README.md');
@NiGhTTraX
NiGhTTraX / test-output.md
Last active June 19, 2019 10:25
Mugshot failing result
Expected Actual Diff
expected actual diff
export function vit(
name: string,
definition: () => Promise<any>,
selector:string = '#root > *'
) {
it(name, async () => {
await definition();
const result = await mugshot.check(name, selector);
expect(result.matches).to.be.true;
module.exports = {
webpack: (config) => {
// Let Babel compile outside of src/.
const tsRule = config.module.rules.find(
(rule) => rule.test && rule.test.toString().includes("tsx|ts")
);
tsRule.include = undefined;
tsRule.exclude = /node_modules/;
return config;
{
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"webpack": true
}
}
module.exports = {
experimental: {
externalDir: true,
},
};