Giter Site home page Giter Site logo

fe-testing-workshops's Introduction

FE TESTING WORKSHOPS

Repository that helps me in presenting: good practices, risks, popular mistakes and proper configuration.

To start dev server

pnpm start -> go to http://localhost:8080/

To start tests

pnpm test

VSCode extensions

  • GOOD: Jest Runner, Jest Snippets
  • AVOID: Jest (makes VSC very slow)

Structure:

  • src
    • components
      • componentFolder
        • componentFile.tsx
        • componentFile.test.tsx
    • utils
      • featureFolder
        • featureFile.ts
        • featureFile.test.ts

Important files

NOTE: you can define jest.config within package.json by putting it inside jest key, see: https://jestjs.io/docs/configuration

Config files

Prettier

Config file as .js to make adding comments possible. Regular json files (e.g. package.json) don't allow comments. Some json (jsonc) files (e.g. tsconfig.json) allow comments but you can't easily recognize them thus using just .js is better.

ESLint

Initial config && dependencies added automatically via npx eslint --init.

Config file as .js to make adding comments possible.

There are two eslint plugins just for testing purposes:

TypeScript reset

If you wondering what's reset.d.ts then see: https://github.com/total-typescript/ts-reset

TypeScript config

Based on @tsconfig/strictest - https://github.com/tsconfig/bases

Articles

https://medium.com/plain-and-simple/arrange-act-assert-vs-given-when-then-c22da421bf75 https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#using-waitfor-to-wait-for-elements-that-can-be-queried-with-find https://kentcdodds.com/blog/avoid-nesting-when-youre-testing

FAQ

Why pnpm?

Because it's significantly faster than npm or yarn: https://pnpm.io/

Why webpack?

Because it's a part of most popular testing setup when Jest is also used.

Why ts-jest?

To be able to use TypeScript in tests.

Why ts-node?

To be able to write (and thus validate) webpack config in TypeScript: https://webpack.js.org/configuration/configuration-languages/

Why ts-loader instead of babel-loader?

I don't need to support https://github.com/browserslist/browserslist in this project, so I can use TypeScript directly as shown in webpack docs: https://webpack.js.org/guides/typescript/

fe-testing-workshops's People

Contributors

kolodziejczakm avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.