Skip to content

Instantly share code, notes, and snippets.

View SebDuf's full-sized avatar
🐧

Sébastien Dufour-Beauséjour SebDuf

🐧
View GitHub Profile
// Before
function getUserFriends(state): Friends[] {
return state.me.friends;
}
// After
function getUserFriends(state): Friends[] {
const friends = [];
// Please never do this; it's only to illustrate the point
{
me: {
id: 'bf6e74fe-9d41-4082-a48c-a2ce6d771da2',
firstName: 'Sébastien',
friendCount: 1,
friend-1: {
id: '7ccc3ebc-9310-426b-8e56-8d58f0a7ce2c',
firstName: 'Peppa'
}
}
{
user: {
id: 'bf6e74fe-9d41-4082-a48c-a2ce6d771da2',
firstName: 'Sébastien',
friends: [
{
id: '7ccc3ebc-9310-426b-8e56-8d58f0a7ce2c',
firstName: 'Peppa'
}
]
cy.visit('http://www.google.com');
cy.title().should('eq', 'Google');
cy.get('input[type=text]').type('nightwatch');
cy.get('button[name=btnG]').click();
cy.contains('The Night Watch');
client.
url('http://www.google.com')
.waitForElementVisible('body', 1000)
.assert.title('Google')
.assert.visible('input[type=text]')
.setValue('input[type=text]', 'nightwatch')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('#main', 'The Night Watch')
export function testId(id: string) {
return `[data-testid="${id}"]`;
}
@SebDuf
SebDuf / .babelrc
Created July 18, 2019 19:29
Lean .babelrc demonstrating how to configure react-remove-properties to remove specific attributes
{
"env": {
"production": {
"plugins": [
[
"react-remove-properties",
{
"properties": [
"data-testid"
]
import { shallow } from 'enzyme';
describe('IncomingCalls component', () => {
describe('given NO calls', () => {
it('should render empty state', async () => {
const component = createComponent({ calls: [] });
expect(component.exists(testId('no-incoming-calls'))).toBeTruthy();
});
export function IncomingCalls({ calls }: Props) {
return (
<div>
<p>
Incoming Calls
</p>
{calls.length > 0 ?
<div data-testid="incoming-call-list">
{calls.map(call => <CallCard key={call.id} call={call} />)}