Skip to content

Instantly share code, notes, and snippets.

@arroyostack
Forked from Klerith/vite-testing-config.md
Last active July 13, 2023 10:33
Show Gist options
  • Save arroyostack/391a69780abea5c896414bc323d68024 to your computer and use it in GitHub Desktop.
Save arroyostack/391a69780abea5c896414bc323d68024 to your computer and use it in GitHub Desktop.

Revisions

  1. arroyostack revised this gist Jul 13, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions vite-testing-config.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Instalación y configuracion de Jest + React Testing Library
    ## En proyectos de React + Vite
    ## Installs and configuration for Jest + React Testing Library
    ## For React + Vite projects

    1. Necessary installs:
    ```
  2. arroyostack revised this gist Jul 13, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vite-testing-config.md
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ yarn add --dev whatwg-fetch
    "test": "jest --watchAll"
    ```

    4. Create babel configuration file __babel.config.js__. Warning if you get module type error rename to extension __.cjs__
    4. Create babel configuration file __babel.config.js__. Warning!: if you get a module type error, rename file to extension __.cjs__
    ```
    module.exports = {
    presets: [
  3. arroyostack revised this gist Jul 13, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vite-testing-config.md
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ yarn add --dev whatwg-fetch
    "test": "jest --watchAll"
    ```

    4. Create babel configuration file __babel.config.js__.
    4. Create babel configuration file __babel.config.js__. Warning if you get module type error rename to extension __.cjs__
    ```
    module.exports = {
    presets: [
  4. arroyostack revised this gist Jul 13, 2023. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions vite-testing-config.md
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,25 @@
    # Instalación y configuracion de Jest + React Testing Library
    ## En proyectos de React + Vite

    1. Instalaciones:
    1. Necessary installs:
    ```
    yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
    yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
    ```

    2. Opcional: Si usamos Fetch API en el proyecto:
    2. Optional: If we use Fetch API in the project:
    ```
    yarn add --dev whatwg-fetch
    ```

    3. Actualizar los scripts del __package.json__
    3. Update __package.json__ scripts
    ```
    "scripts: {
    ...
    "test": "jest --watchAll"
    ```

    4. Crear la configuración de babel __babel.config.js__
    4. Create babel configuration file __babel.config.js__.
    ```
    module.exports = {
    presets: [
    @@ -29,7 +29,7 @@ module.exports = {
    };
    ```

    5. Opcional, pero eventualmente necesario, crear Jest config y setup:
    5. Optional, but eventually necessary, create Jest config and setup:

    __jest.config.js__
    ```
    @@ -41,7 +41,7 @@ module.exports = {

    __jest.setup.js__
    ```
    // En caso de necesitar la implementación del FetchAPI
    // In case you need to implement the FetchAPI
    import 'whatwg-fetch'; // <-- yarn add whatwg-fetch
    ```

  5. @Klerith Klerith revised this gist Apr 28, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions vite-testing-config.md
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,7 @@ module.exports = {
    ```

    5. Opcional, pero eventualmente necesario, crear Jest config y setup:

    __jest.config.js__
    ```
    module.exports = {
  6. @Klerith Klerith revised this gist Apr 28, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vite-testing-config.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
    yarn add --dev whatwg-fetch
    ```

    3. Actualizar los scripts del __package.json___
    3. Actualizar los scripts del __package.json__
    ```
    "scripts: {
    ...
  7. @Klerith Klerith revised this gist Apr 28, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vite-testing-config.md
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ module.exports = {
    ```

    5. Opcional, pero eventualmente necesario, crear Jest config y setup:
    __jest.config.js___
    __jest.config.js__
    ```
    module.exports = {
    testEnvironment: 'jest-environment-jsdom',
  8. @Klerith Klerith revised this gist Apr 28, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions vite-testing-config.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    # Instalación y configuracion de Jest + React Testing Library
    ## En proyectos de React + Vite

    1. Instalaciones:
    ```
    yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
  9. @Klerith Klerith created this gist Apr 28, 2022.
    44 changes: 44 additions & 0 deletions vite-testing-config.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    1. Instalaciones:
    ```
    yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
    yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
    ```

    2. Opcional: Si usamos Fetch API en el proyecto:
    ```
    yarn add --dev whatwg-fetch
    ```

    3. Actualizar los scripts del __package.json___
    ```
    "scripts: {
    ...
    "test": "jest --watchAll"
    ```

    4. Crear la configuración de babel __babel.config.js__
    ```
    module.exports = {
    presets: [
    [ '@babel/preset-env', { targets: { esmodules: true } } ],
    [ '@babel/preset-react', { runtime: 'automatic' } ],
    ],
    };
    ```

    5. Opcional, pero eventualmente necesario, crear Jest config y setup:
    __jest.config.js___
    ```
    module.exports = {
    testEnvironment: 'jest-environment-jsdom',
    setupFiles: ['./jest.setup.js']
    }
    ```

    __jest.setup.js__
    ```
    // En caso de necesitar la implementación del FetchAPI
    import 'whatwg-fetch'; // <-- yarn add whatwg-fetch
    ```