Amaury Liet
Développeur
front & back end
AmauryLiet
import React from 'react';
import { shallow } from 'enzyme';
it('should do something when clicking on the delete button', () => {
const fakeData = {
items: [
{
id: 1,
value: '',
},
],
};
const deleteItemMock = jest.fn(() => Promise.resolve(true));
const component = shallow(
<TestedComponent
data={fakeData}
deleteBusinessFunction={deleteBusinessFunction}
/>
);
component
.find('tr')
.at(1)
.find('td')
.at(5)
.children()
.at(0)
.simulate('click');
expect(deleteItemMock).toHaveBeenCalledWith({
variables: {
id: 1,
},
});
});
10 minutes (par test)
* 2 tests (par composant)
* 100 composants
= 2000 minutes
= 1 semaine
import React from 'react';
import { shallow } from 'enzyme';
it('should do something when clicking on the delete button', () => {
const fakeData = {
items: [
{
id: 1,
value: '',
},
],
};
import React from 'react';
import { shallow } from 'enzyme';
it('should do something when clicking on the delete button', () => {
const fakeData = {
items: [
{
id: 1,
value: '',
},
],
};
const deleteItemMock = jest.fn(() => Promise.resolve(true));
import React from 'react';
import { shallow } from 'enzyme';
it('should do something when clicking on the delete button', () => {
const fakeData = {
items: [
{
id: 1,
value: '',
},
],
};
const deleteItemMock = jest.fn(() => Promise.resolve(true));
const component = shallow(
<TestedComponent
data={fakeData}
deleteBusinessFunction={deleteBusinessFunction}
/>
);
component
.find('tr')
.at(1)
.find('td')
.at(5)
.children()
.at(0)
import React from 'react';
import { shallow } from 'enzyme';
it('should do something when clicking on the delete button', () => {
const fakeData = {
items: [
{
id: 1,
value: '',
},
],
};
const deleteItemMock = jest.fn(() => Promise.resolve(true));
const component = shallow(
<TestedComponent
data={fakeData}
deleteBusinessFunction={deleteBusinessFunction}
/>
);
component
.find('tr')
.at(1)
.find('td')
.at(5)
.children()
.at(0)
.simulate('click');
import React from 'react';
import { shallow } from 'enzyme';
it('should do something when clicking on the delete button', () => {
const fakeData = {
items: [
{
id: 1,
value: '',
},
],
};
const deleteItemMock = jest.fn(() => Promise.resolve(true));
const component = shallow(
<TestedComponent
data={fakeData}
deleteBusinessFunction={deleteBusinessFunction}
/>
);
10 minutes (par test)
* 2 tests (par composant)
* 100 composants
Un abstract syntax tree ou AST (arbre syntaxique abstrait, en français) est un arbre dont les nœuds internes sont marqués par des opérateurs et dont les feuilles (ou nœuds externes) représentent les opérandes de ces opérateurs
Votre code transformé en une structure compréhensible par votre ordinateur
✅ C'est moins cher que les tests
(création & maintenabilité)
✅ Le "dev feedback time" est excellent
✅ Ça scale à volonté
✅ Analysez vos bugs