interstellard / chatgpt-advanced

WebChatGPT: A browser extension that augments your ChatGPT prompts with web results.
https://webchatgpt.app
MIT License
6.44k stars 838 forks source link

Add Jest Testing #122

Closed maxsu closed 1 year ago

maxsu commented 1 year ago
  1. Add a testing script: "test": "jest" 🤡

  2. Add html testing: *@testing-library/jest-domt ref: dom testing guide

  3. Add preact testing: @testing-library/preact ref: preact component testing guide

  4. Add typescript tests: ts-jest

  5. Use a typescript jest.config file: ts-node

  6. Add jest.config.ts:

    • root: The project's import root is /src
    • transform: Translate .ts/.tsx tests using ts-jest
    • testRegex: Tests files are
      1. Any .ts/.tsx file in /src/__tests__/ (for example: /src/__tests__/index.ts, /src/__tests__/example.test.ts)
      2. Any file named /src/**/*.test.[ts,tsx]
      3. Any file named /src/**/*.spec.[ts,tsx]
      4. Any file named /src/**/test.[ts,tsx]
      5. Any file named /src/**/spec.[ts,tsx]
    • moduleFileExtensions: Jest tests may import ts, tsx, js, jsx, mjs, and json modules, and also node binary modules.
    • setupFilesAfterEnv: install jest-dom for each test module
  7. Added /srt/__tests__/example.test.ts

To run tests, perform npm test.

Breaking Changes: None.