Skip to content

Commit

Permalink
✨ improve e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yago committed Aug 10, 2020
1 parent 17e525d commit 45f8c25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 14 additions & 3 deletions cypress/integration/first-test.js
@@ -1,8 +1,19 @@
/* globals cy */

describe('Homepage', () => {
it('should perform basic google search', () => {
cy.visit('/');
cy.get('#count').should('have.length', 1);
beforeEach(() => cy.visit('/'));

it('should display the count', () => {
cy.get('#counter > span').should('have.length', 1);
});

it('should increase the count', () => {
cy.get('#counter > button:last-child').click();
cy.get('#counter > span').should('contain', '1');
});

it('should decrease the count', () => {
cy.get('#counter > button:first-child').click();
cy.get('#counter > span').should('contain', '-1');
});
});
6 changes: 2 additions & 4 deletions playground/src/components/Counter/Counter.tsx
Expand Up @@ -7,17 +7,15 @@ const Counter = (): JSX.Element => {
const [count, setCount] = useState(0);

return (
<div tw="flex items-center justify-center w-full h-screen">
<div id="counter" tw="flex items-center justify-center w-full h-screen">
<button
type="button"
onClick={() => setCount(i => i - 1)}
tw="bg-blue-500 text-white rounded py-2 px-4"
>
-
</button>
<span id="count" tw="px-4 font-bold text-2xl">
{count}
</span>
<span tw="px-4 font-bold text-2xl">{count}</span>
<button
type="button"
onClick={() => setCount(i => i + 1)}
Expand Down

0 comments on commit 45f8c25

Please sign in to comment.