I would like to solve the problem of stubs in a way that allows us to easily extend them. I would also like to prevent the stubs to go stale and I would like to have it defined in a central place. Let me show you what I have in mind on the next files.
This file contains 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
#!/bin/bash | |
# gh is the GitHub CLI | |
ORG='cdk8s-team' | |
gh repo list cdk8s-team --json "name" | jq -r ".[] | .name" | xargs -I '{}' gh repo clone "cdk8s-team/{}" |
This file contains 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
#!/usr/bin/env node | |
// Generates renovate config to fix @types and package running out of sync | |
// See https://github.com/renovatebot/renovate/issues/4893 | |
const path = require("path"); | |
const fs = require("fs"); | |
// This script lies under scripts/update-renovate.js, therefore the .. | |
const renovatePath = path.resolve(__dirname, "../renovate.json"); |
This file contains 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, { Component } from 'react'; | |
import { | |
StyleSheet, | |
Text, | |
View | |
} from 'react-native'; | |
import { Accelerometer } from "react-native-sensors"; | |
const Value = ({name, value}) => ( | |
<View style={styles.valueContainer}> |
This file contains 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, { Component } from "react"; | |
import { StyleSheet, Text, View, Image } from "react-native"; | |
import { Gyroscope } from "react-native-sensors"; | |
const Dimensions = require("Dimensions"); | |
const PixelRatio = require("PixelRatio"); | |
const window = Dimensions.get("window"); | |
const deviceWidth = window.width; | |
const deviceHeight = window.height; |
Run this on your tests to remove every this.foo
from the tests
npm install -g jscodeshift
jscodeshift --transform https://gist.githubusercontent.com/DanielMSchmidt/9e1bc548ab5d8d1a3fadddc2d735f8c2/raw/808d337f6088ff62feae99115edaf59a6c333b1a/transform.js ./**/__tests__/*.js
This file contains 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
const tracer = ... // As previously defined | |
tracer.scoped(() => { | |
// Previous example | |
const previousResult = 404; | |
tracer.scoped(() => { | |
const id = tracer.createChildId(); | |
tracer.setId(id); | |
tracer.recordAnnotation(new zipkin.Annotation.ClientSend()); |
This file contains 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
const tracer = ... // like defined before | |
function loadFromLocalStorage() { return new Promise(...) } | |
tracer.local("load", loadFromLocalStorage()).then(loadedData => { | |
tracer.local("compute", () => { | |
runComputationOn(loadedData); | |
}); | |
}); |
This file contains 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
const tracer = ... // See example above | |
tracer.scoped(() => { | |
const id = tracer.createRootId(); | |
tracer.setId(id); | |
tracer.recordAnnotation(new zipkin.Annotation.ClientSend()); | |
tracer.recordAnnotation(new zipkin.Annotation.Rpc("My Span")); |
This file contains 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 zipkin from "zipkin"; | |
import { HttpLogger } from "zipkin-transport-http"; | |
const tracer = new zipkin.Tracer({ | |
ctxImpl: new zipkin.ExplicitContext(), | |
recorder: new zipkin.BatchRecorder({ | |
logger: new HttpLogger({ | |
endpoint: 'http://localhost:9411/api/v2/spans', | |
jsonEncoder: zipkin.jsonEncoder.JSON_V2, | |
fetch |
NewerOlder