Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
feat: support testing React components that use hooks
Browse files Browse the repository at this point in the history
breaking change: requires Cypress v4.5.0 with experimental component testing flag,
and the mounting API has changed.

Squashed commit of the following:

commit 7636302
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Apr 28 17:48:42 2020 -0400

    update style test

commit 6eab8b0
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Apr 28 17:33:41 2020 -0400

    use Cypress v4.5.0

commit 78e2b63
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Apr 28 11:24:04 2020 -0400

    fix: add link to example, remove stray console.log

commit 7b7460d
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 14:58:40 2020 -0400

    fix: upgrade find-webpack

commit f7ff96e
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 14:56:11 2020 -0400

    fix: remove dupicate code

commit 106e658
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 12:38:22 2020 -0400

    add more lines to the table

commit 53046a7
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 11:32:14 2020 -0400

    update Jest vs cypress-react-unit-test table in the README

commit fd67ac7
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 10:33:10 2020 -0400

    point plugins at index file

commit a16c802
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 10:18:38 2020 -0400

    slightly better console log

commit ffcc1ee
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 09:56:46 2020 -0400

    fix: add math random to component key prop on mount

commit 222b6c2
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 09:53:04 2020 -0400

    fix: cypress-jsdom -> cypress-root

commit 9d49151
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 08:50:53 2020 -0400

    add counter with hooks spec

commit 5d7b3e2
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 08:41:31 2020 -0400

    add demo animated gif

commit c17f88e
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 27 08:38:51 2020 -0400

    change babelrc recipe to use explicit plugins file

commit c130dc4
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 24 16:33:30 2020 -0400

    add link

commit efe88d6
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 24 16:19:39 2020 -0400

    downgraded to testing-library cypress 5

commit 11e610c
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 24 16:15:46 2020 -0400

    upgrade cypress to v4.4.1

commit b1a7f1b
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 24 14:35:16 2020 -0400

    lock file update

commit 7d733c1
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 24 14:33:44 2020 -0400

    feat: add babelrc preprocessor, closes #149

commit 79f2130
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 24 12:42:54 2020 -0400

    add visual testing link

commit a6eb6d8
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 24 12:41:45 2020 -0400

    add note about testing library

commit 95caa6a
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 24 08:23:50 2020 -0400

    add react-loading-skeleton example link

commit 1c9a99f
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 23 14:19:24 2020 -0400

    add lodash/fp spec

commit 9f77d37
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 23 08:50:08 2020 -0400

    add storybook-code-coverage link

commit 00ff13b
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 22 16:56:59 2020 -0400

    add full list of advanced examples

commit 8d719da
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 22 16:32:18 2020 -0400

    expand list of basic examples

commit 2c35076
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 22 15:36:47 2020 -0400

    more doc tweaks

commit f9b0c05
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 22 15:06:29 2020 -0400

    split long readme into docs files

commit 85e73cb
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 20 16:57:55 2020 -0400

    renderless example

commit 615bd04
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 16 22:53:04 2020 -0400

    feat: respect log false

commit ad51a71
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 16 22:44:43 2020 -0400

    feat: reset the styles better

commit fffd891
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 16 22:17:25 2020 -0400

    clean up any injected styles before each test

commit 298725f
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 16 15:51:11 2020 -0400

    feat: add css aliases to mounting options

commit 9d06119
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 16 15:36:27 2020 -0400

    fix: force return value

commit 4dbee03
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 16 14:03:50 2020 -0400

    fix: encode image

commit a62fc22
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 16 13:44:04 2020 -0400

    feat: if serving outside resource, serve base64 image

commit b5686c3
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 16 13:29:38 2020 -0400

    feat: add image rule for both plugins

commit 12d859e
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 16 10:17:32 2020 -0400

    feat: redirect images to __root

commit 6fb6fc2
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Apr 14 10:36:02 2020 -0400

    link v2 issues

commit 22eec19
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Apr 14 10:08:59 2020 -0400

    fix: take default object from loaded webpack config

commit e64620f
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Apr 14 08:36:49 2020 -0400

    link to resource issue

commit 584da55
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 13 18:13:14 2020 -0400

    update README

commit ea4aaf8
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 13 18:03:45 2020 -0400

    second rename

commit 56132ff
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 13 18:02:41 2020 -0400

    rename component test folder

commit 61d95fb
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 13 17:56:30 2020 -0400

    add TSX component example

commit d1aece8
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 9 14:52:49 2020 -0400

    feat: update style options and document them well

commit 1d2c411
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 9 14:17:40 2020 -0400

    chore: refactor style injection

commit 0f2defa
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 8 09:19:59 2020 -0400

    comment out import syntax

commit f72b7d3
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 8 09:14:48 2020 -0400

    feat: correctly clean up webpack for react-scripts for lazy dynamic imports

commit 3bee1e2
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 8 08:43:00 2020 -0400

    feat: support lazy-loaded components by forcing all into 1 chunk

commit 5bbcc69
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 6 20:04:19 2020 -0400

    feat: allow loading webpack config by filename

commit b5fcf70
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 6 16:32:33 2020 -0400

    move webpack clean up to find-webpack

commit 62ff7c5
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 6 16:02:27 2020 -0400

    fix the require

commit 60fa438
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Apr 6 16:00:15 2020 -0400

    feat: use new code coverage version

commit ddbdbe2
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Apr 5 22:47:44 2020 -0400

    feat: use find-webpack to handle ejected react-scripts too

commit 33a5353
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Apr 5 19:20:22 2020 -0400

    add link to react animations example

commit 1ee7668
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Apr 5 18:46:31 2020 -0400

    remove commit again

commit f7678b8
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Apr 5 18:07:19 2020 -0400

    fix: update code coverage with better filtering

commit ed33d6a
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Apr 5 18:05:22 2020 -0400

    add links to more projects and full cypress json file

commit e9773d9
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sat Apr 4 17:20:31 2020 -0400

    fix: new code coverage plugin version

commit cc90fea
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sat Apr 4 16:34:46 2020 -0400

    fix: support file should load hooks

commit 1715052
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sat Apr 4 16:17:48 2020 -0400

    remove release plugins again

commit 5f4856c
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sat Apr 4 15:55:42 2020 -0400

    feat: include code-coverage plugin for react-scripts

commit c379d01
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sat Apr 4 16:11:40 2020 -0400

    updated package lock

commit 3e12870
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sat Apr 4 14:33:37 2020 -0400

    feat: add built-in code instrumentation

commit fbd07b1
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 3 17:29:51 2020 -0400

    feat: support cssFile style

commit 796d248
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 3 13:18:24 2020 -0400

    fix: include dist/hooks

commit df33cab
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 3 12:58:44 2020 -0400

    fix: include plugins and support in dist

commit 53483df
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 3 12:11:11 2020 -0400

    chore: remove commit plugins

commit 04f1db4
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 3 11:33:57 2020 -0400

    feat: add plugins and support for react-scripts

commit a44405e
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Apr 3 11:19:37 2020 -0400

    chore: update dependencies

commit 1afb662
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 16:38:08 2020 -0400

    remove unnecessary flag

commit dd92d56
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 15:56:24 2020 -0400

    feat: change to experimental mount mode to support React Hooks

    BREAKING CHANGE: the plugin's API has changed.

commit be59374
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 15:45:30 2020 -0400

    hmm

commit 2b3f6fb
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 15:33:57 2020 -0400

    try assigning channel and reusing this branch name

commit 67d44cb
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 15:11:16 2020 -0400

    change branch name

commit 8857c99
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 14:58:43 2020 -0400

    disable PR check for semantic release

commit 98fcc6b
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 14:48:46 2020 -0400

    disable new tests for now

commit 95feb07
Merge: ba6b20c d29901e
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 14:36:04 2020 -0400

    merge master into this branch

commit ba6b20c
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 14:18:36 2020 -0400

    no module for now

commit d29901e
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 13:37:12 2020 -0400

    remove emoji from circle job names

commit 5ea2b4a
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 12:04:37 2020 -0400

    chore: add comments to circle file

commit 34e1072
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 10:30:41 2020 -0400

    feat: allow passing just cssFile path to inject style

commit 72799e2
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Apr 2 10:18:34 2020 -0400

    feat: add style option

commit a7916c3
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 1 15:22:43 2020 -0400

    fix: handle bare div mount (#118)

commit 8a23f96
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 1 14:50:38 2020 -0400

    Upgrade webpack preprocessor (#117)

    * install new webpack preprocessor v4

    * remove old code

    * Node 8

commit 4e2f899
Author: Neale Upstone <neale@nealeupstone.com>
Date:   Wed Apr 1 19:28:39 2020 +0100

    feat: allow consuming projects to use noImplicitAny and fix JSX

    * tsc: Enable noImplicitAny and fix type issues that showed up

    * Replace Symbol with JSXElement to address JSX.Element -> Symbol errors (#55)

    * tsc: Enable strictNullChecks and fix type issues that showed for some users

    * remove stray JSX

    Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>

commit 93e0fef
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 1 14:15:18 2020 -0400

    use newer Node for semantic release job

commit c4eb69b
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 1 14:09:18 2020 -0400

    add semantic release job

commit a7967a9
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 1 14:07:49 2020 -0400

    chore: set up semantic release

commit 38e0640
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 1 14:05:38 2020 -0400

    remove old semantic-action

commit ac53220
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 1 14:00:06 2020 -0400

    upgrade Cypress to v4.3.0

commit c274025
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 1 13:53:14 2020 -0400

    add cirlce

commit 3c3e9d3
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Apr 1 00:01:57 2020 -0400

    add full material ui list demo

commit 962ea87
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Mar 31 23:54:16 2020 -0400

    move emotion to dev dependency

commit cbd83da
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Mar 31 23:40:07 2020 -0400

    singular

commit dc5d983
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Feb 26 09:52:59 2020 -0500

    disable a test

commit 7a609dd
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Feb 13 21:44:02 2020 -0500

    add react-router v6 alpha test

commit ca3b232
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Jan 28 15:18:22 2020 -0500

    update comments

commit 0207966
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Jan 28 14:57:26 2020 -0500

    looking at window reference

commit 8963ab4
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Jan 17 15:03:27 2020 -0500

    all tests from react soft book

commit 6a32d35
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Jan 16 19:34:00 2020 -0500

    autocomplete material component

commit 9736a5c
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Jan 16 19:23:30 2020 -0500

    test ratings component

commit 8d817a2
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Jan 16 19:11:51 2020 -0500

    allow injecting styles and stylesheets

commit 0e2a699
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Jan 13 18:12:12 2020 -0500

    update xhr test a little

commit 7ba50de
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Jan 13 17:56:46 2020 -0500

    add react book tests

commit 3a4c7e0
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Jan 10 15:26:56 2020 -0500

    add example

commit 96f339e
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Jan 10 15:24:02 2020 -0500

    add example of unit testing tic tac toe win logic

commit 92b3d28
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Jan 10 11:47:44 2020 -0500

    add unmount function

commit 30bf202
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Jan 10 11:32:34 2020 -0500

    add timers tests

commit b2b10fe
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Jan 10 11:10:17 2020 -0500

    try snapshot plugins

commit e2093ca
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Jan 10 10:54:22 2020 -0500

    full tutorial with css

commit 237ff76
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Jan 10 10:27:26 2020 -0500

    add react tutorial specs

commit dde0331
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Jan 8 14:01:12 2020 -0500

    reorganize tests

commit 38237bf
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Jan 6 09:36:07 2020 -0500

    add component interaction

commit 0bfae9c
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 15:37:45 2020 -0500

    check for spec type to be component instead of mount mode

commit 8b4cd7a
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 12:53:12 2020 -0500

    set custom VSCode color

commit 62e2199
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 12:52:03 2020 -0500

    move component tests to component subfolder

commit 949376e
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 12:45:08 2020 -0500

    format and lint on commit hook

commit 7f40b07
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 12:43:44 2020 -0500

    format all cypress subfolders

commit 6f4ba52
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 12:43:18 2020 -0500

    format lib ts files

commit b53b736
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 12:42:43 2020 -0500

    format integration files

commit 2173720
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 12:41:50 2020 -0500

    formatting src jsx

commit e324d29
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 12:41:42 2020 -0500

    formatting src jsx

commit 60d4c32
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Sun Jan 5 12:40:10 2020 -0500

    adding prettier

commit 8078bea
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Jan 2 16:21:28 2020 -0500

    tried two examples from material ui

commit 0be1aa3
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Dec 27 11:07:29 2019 -0500

    example mocking named ES6 imports

commit e55433d
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Fri Dec 27 10:07:31 2019 -0500

    rename

commit 311b456
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Thu Dec 26 12:59:55 2019 -0500

    working mocking module

commit 60976e8
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Wed Dec 25 00:05:00 2019 -0500

    toggle example test

commit 0c1d115
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Dec 24 23:57:08 2019 -0500

    example unfinished of mocking modules

commit 7791727
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Dec 24 23:42:05 2019 -0500

    add mocking fetch example

commit 4f471b2
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Dec 24 23:22:11 2019 -0500

    add example from react testing docs

commit 36e8976
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Dec 24 23:16:24 2019 -0500

    test unmount

commit a836bd3
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Dec 24 14:48:45 2019 -0500

    complete example, svg and styles

commit 894436d
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Dec 24 14:31:00 2019 -0500

    add example with set timeout

commit b08f16c
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Dec 24 14:06:18 2019 -0500

    tried cy stub example

commit f24784b
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Dec 24 10:39:52 2019 -0500

    add cypress-testing-lib commands to check

commit 2616a30
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Tue Dec 24 10:33:35 2019 -0500

    test equivalent to react-testing lib example

commit cbe2e77
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Dec 23 17:32:58 2019 -0500

    add React Context example test

commit dce046b
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Dec 23 17:22:00 2019 -0500

    add more examples from React tutorial

commit a7e7b38
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Dec 23 16:38:43 2019 -0500

    another emotion example

commit 4c0c1db
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Dec 23 16:23:02 2019 -0500

    add another hooks example with useEffect

commit f70af39
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Date:   Mon Dec 23 08:47:55 2019 -0500

    package lock

commit c029c4a
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Wed Dec 18 16:17:31 2019 +0200

    Remove .log file

commit fea1996
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Wed Dec 18 16:16:45 2019 +0200

    Fix error boundary example

commit d4ef1af
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Wed Dec 18 15:57:26 2019 +0200

    Move hooks out

commit f1e7580
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Wed Dec 18 15:00:52 2019 +0200

    Add portal test

commit d4be565
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Wed Dec 18 15:00:49 2019 +0200

    Fix emotion test

commit 574cc62
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Wed Dec 18 15:00:37 2019 +0200

    Do not delete loaded scripts when prepearing to ReactDom.render

commit 928d102
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Mon Dec 16 16:10:07 2019 +0200

    Add emotion test

commit f6f1197
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Mon Dec 16 15:10:33 2019 +0200

    Unmount components after tests

commit 20c1e7a
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Sun Dec 15 15:02:20 2019 +0200

    Rewrite spec files

commit 26eb3ea
Author: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Date:   Sun Dec 15 14:24:20 2019 +0200

    Use mount mode to render components
  • Loading branch information
bahmutov committed Apr 28, 2020
1 parent 3e1f085 commit b1cca0f
Show file tree
Hide file tree
Showing 197 changed files with 23,127 additions and 10,700 deletions.
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ public/
node_modules/
dist
cypress/videos
cypress/screenshots
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

28 changes: 26 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
{
"git.ignoreLimitWarning": true,
"eslint.enable": false
}
"eslint.enable": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
"workbench.colorCustomizations": {
"activityBar.background": "#a7cf00",
"activityBar.activeBackground": "#a7cf00",
"activityBar.activeBorder": "#00819f",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#00819f",
"activityBarBadge.foreground": "#e7e7e7",
"titleBar.activeBackground": "#7e9c00",
"titleBar.inactiveBackground": "#7e9c0099",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveForeground": "#15202b99",
"statusBar.background": "#7e9c00",
"statusBarItem.hoverBackground": "#556900",
"statusBar.foreground": "#15202b",
"statusBar.border": "#7e9c00",
"titleBar.border": "#7e9c00"
},
"peacock.color": "#7e9c00",
"javascript.updateImportsOnFileMove.enabled": "never",
"typescript.updateImportsOnFileMove.enabled": "never"
}
281 changes: 157 additions & 124 deletions README.md

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
presets: [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
// allow lazy loaded components with dynamic "import(...)"
// https://babeljs.io/docs/en/babel-plugin-syntax-dynamic-import/
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-class-properties',
// https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs
// loose ES6 modules allow us to dynamically mock imports during tests
[
'@babel/plugin-transform-modules-commonjs',
{
loose: true,
},
],
[
'module-resolver',
{
alias: {
'cypress-react-unit-test': './dist',
},
},
],
],
}
54 changes: 54 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: 2.1
orbs:
cypress: cypress-io/cypress@1
workflows:
build:
jobs:
# install and cache dependencies in this job
# AND build the library once
# then the workspace will be passed to other jobs
- cypress/install:
name: Install
build: npm run transpile
post-steps:
- run:
name: Show info 📺
command: npx cypress info
- run:
name: Linting code 🧹
command: npm run lint

# the test job automatically attaches the workspace
# created by the install job, so it is ready to test
- cypress/run:
name: Test
requires:
- Install
# notice a trick to avoid re-installing dependencies
# in this job - a do-nothing "install-command" parameter
install-command: echo 'Nothing to install in this job'
# we are not going to use results from this job anywhere else
no-workspace: true
record: false

# this job attaches the workspace left by the install job
# so it is ready to run Cypress tests
# only we will run semantic release script instead
- cypress/run:
name: NPM release
# we need newer Node for semantic release
executor: cypress/base-12-6-0
requires:
- Install
- Test
install-command: echo 'Nothing to install in this job'
no-workspace: true
# instead of "cypress run" do NPM release 😁
# clear environment variables to trick semantic-release
# into thinking this is NOT a pull request.
# (under the hood the module env-ci is used to check if this is a PR)
command: |
CIRCLE_PR_NUMBER= \
CIRCLE_PULL_REQUEST= \
CI_PULL_REQUEST= \
npm run semantic-release
13 changes: 9 additions & 4 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"viewportWidth": 300,
"viewportHeight": 100,
"viewportWidth": 400,
"viewportHeight": 400,
"video": false,
"projectId": "z9dxah",
"ignoreTestFiles": "*.css",
"testFiles": "**/*spec.{js,jsx,ts,tsx}",
"env": {
"cypress-react-unit-test": {
"react": "node_modules/react/umd/react.development.js",
"react-dom": "node_modules/react-dom/umd/react-dom.development.js"
}
}
},
"ignoreTestFiles": [
"**/__snapshots__/*",
"**/__image_snapshots__/*"
],
"experimentalComponentTesting": true
}
1 change: 1 addition & 0 deletions cypress/component/advanced/app-action-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Example showing how a component exposes a reference from its constructor, allowing the test to interact with the component's internals.
34 changes: 34 additions & 0 deletions cypress/component/advanced/app-action-example/counter-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/// <reference types="cypress" />
import React from 'react'
import { mount } from 'cypress-react-unit-test'
import { Counter } from './counter.jsx'

/* eslint-env mocha */
describe('Counter with access', () => {
it('works', () => {
mount(<Counter />)
cy.contains('count: 0')
.click()
.contains('count: 1')
.click()
.contains('count: 2')
})

it('allows access via reference', () => {
mount(<Counter />)

// the window.counter was set from the Counter's constructor
cy.window()
.should('have.property', 'counter')
.its('state')
.should('deep.equal', { count: 0 })
// let's change the state of the component
cy.window()
.its('counter')
.invoke('setState', {
count: 101,
})
// the UI should update to reflect the new count
cy.contains('count: 101').should('be.visible')
})
})
33 changes: 33 additions & 0 deletions cypress/component/advanced/app-action-example/counter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react'

export class Counter extends React.Component {
constructor(props) {
super(props)
this.state = {
count: 0,
}

if (window.Cypress) {
// if this component is mounted from inside Cypress Test Runner
// then expose the reference to this instance
// to allow controlling it from tests
console.log(
'set window.counter to this component in window',
window.location.pathname,
)
window.counter = this
} else {
console.log('running outside Cypress')
}
}

click = () => {
this.setState({
count: this.state.count + 1,
})
}

render() {
return <p onClick={this.click}>count: {this.state.count}</p>
}
}
43 changes: 43 additions & 0 deletions cypress/component/advanced/context/context-example.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react'

// Context lets us pass a value deep into the component tree
// without explicitly threading it through every component.
// Create a context for the current theme (with "light" as the default).
const ThemeContext = React.createContext('light')

export default class App extends React.Component {
render() {
// Use a Provider to pass the current theme to the tree below.
// Any component can read it, no matter how deep it is.
// In this example, we're passing "dark" as the current value.
return (
<ThemeContext.Provider value="dark">
<Toolbar />
</ThemeContext.Provider>
)
}
}

// A component in the middle doesn't have to
// pass the theme down explicitly anymore.
function Toolbar(props) {
return (
<div>
<ThemedButton />
</div>
)
}

function Button(props) {
return <button>{props.theme}</button>
}

class ThemedButton extends React.Component {
// Assign a contextType to read the current theme context.
// React will find the closest theme Provider above and use its value.
// In this example, the current theme is "dark".
static contextType = ThemeContext
render() {
return <Button theme={this.context} />
}
}
11 changes: 11 additions & 0 deletions cypress/component/advanced/context/context-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import { mount } from 'cypress-react-unit-test'
import App from './context-example.jsx'

describe('Context example', () => {
it('renders', () => {
mount(<App />)
// the label "dark" was passed through React context
cy.contains('button', 'dark').should('be.visible')
})
})
9 changes: 9 additions & 0 deletions cypress/component/advanced/forward-ref/forward-ref.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

const Button = React.forwardRef(({ children, ...rest }, ref) => (
<button {...rest} ref={ref}>
{children}
</button>
))

export default Button
27 changes: 27 additions & 0 deletions cypress/component/advanced/forward-ref/forward-ref.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference types="cypress" />
/// <reference types="../../lib" />

import React from 'react'
import ReactDom from 'react-dom'
import { mount } from 'cypress-react-unit-test'
import Button from './forward-ref.jsx'

/* eslint-env mocha */
describe('Button component', function() {
it('works', function() {
mount(<Button>Hello, World</Button>)
cy.contains('Hello, World')
})

it('forwards refs as expected', function() {
const ref = React.createRef()

mount(
<Button className="testing" ref={ref}>
Hello, World
</Button>,
)
expect(ref).to.have.property('current')
// expect(ref.current).not.be.null;
})
})
18 changes: 18 additions & 0 deletions cypress/component/advanced/hooks/counter-with-hooks.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'

export default function CounterWithHooks({ initialCount = 0 }) {
const [count, setCount] = React.useState(initialCount)

const handleCountIncrement = React.useCallback(() => {
setCount(count + 1)
}, [count])

return (
<>
<div className="counter">{count}</div>
<button id="increment" onClick={handleCountIncrement}>
+
</button>
</>
)
}
Loading

0 comments on commit b1cca0f

Please sign in to comment.