Wilson Mendes
@willmendesneto
Google Developer Expert Web Technologies
1. Access https://goo.gl/PibUcQ
2. Decrease the price to $0,00
3. Enjoy
...
it('should do something', () => {
expect(true).toBeTruthy();
expect(false).toBeTruthy;
});
...
...
it('should do something', () => {
expect(true).toBeTruthy();
expect(false).toBeTruthy;
});
...
describe('<MyComponent />', () => {
it('should render component', () => {
expect(
mount(<MyComponent />)
)
.toHaveLength(1);
});
it('should render component with given test', () => {
expect(
mount(<MyComponent myText="My example"/>).text()
)
.toEqual('My example');
});
});
import React, { Component } from 'react'
import {
FeatureToggleProvider
} from 'reactor-feature-toggle'
import { MyAmazingAplication } from 'some-package'
const AppWrapper = () => {
const featureToggleData = {
enableMainContent: true,
enableSecondContent: false
};
return (
<FeatureToggleProvider
featureToggleService={featureToggleData}
>
<MyAmazingAplication />
</FeatureToggleProvider>
);
};
export default AppWrapper;
import React, { Component } from 'react'
import {
FeatureToggle
} from 'reactor-feature-toggle'
const MyAmazingApplication = () => {
return (
<FeatureToggle featureName={'enableMainContent'} >
<div className="content">
<p>This content is enabled</p>
<FeatureToggle featureName={'enableSecondContent'} >
<p>This content is disabled</p>
</FeatureToggle>
</div>
</FeatureToggle>
);
};
export default MyAmazingApplication;
describe('<FeatureToggle />', () => {
const aChildComponent = <div>Yay I am a child</div>;
it('should render children if is enabled', () => {
expect(shallow(
<FeatureToggle
featureName={featureNames.thisOneIsEnabled}
>
{aChildComponent}
</FeatureToggle>
)).contains(aChildComponent)).toEqual(true);
});
it('should NOT render children if is NOT enabled', () => {
expect(shallow(
<FeatureToggle
featureName={featureNames.thisOneIsDisabled}
>
{aChildComponent}
</FeatureToggle>
)).contains(aChildComponent)).toEqual(false);
});
});
Wilson Mendes
@willmendesneto
is...
# Running tests in parallel
# using Makefile
...
PATH := $(PATH):node_modules/.bin
SHELL := bash -eu -o pipefail -c
CPUS ?= $(
shell node -p "require('os').cpus().length" 2> /dev/null \
|| echo 1
)
MAKEFLAGS += --warn-undefined-variables --no-builtin-rules \
--output-sync
MAKEFLAGS += --jobs $(CPUS)
...
# Running test in different
# threads using Makefile
# Running test in different
# threads using Jest
jest --coverage --maxWorkers=4
https://goo.gl/37eUr9
https://goo.gl/wQQ7yh
https://goo.gl/E7Ffzr
Wilson Mendes
@willmendesneto
Google Developer Expert Web technologies