Setup Mocha to be Working with Typescript [TDD Mocha for Typescript]

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024
  • This video is part of TDD Mocha for Typescript: • Install Typescript & T...
    If you haven't watch the previous video, go here: • Install Mocha [TDD Moc...
    In this final part of the video, we'll get to setup mocha so it will working well with Typescript.
    Also, we will see the problem that we will face and how to fix it.
    Hope it helps! If you have any question, just ask in the comment section.
    Thank you for watching! Don't forget to Like, Subscribe and Turn on your Notification! See yaaa!

Комментарии • 11

  • @purviagarwal9207
    @purviagarwal9207 3 года назад +1

    Thanks for this. This is definitely the best I could find for beginners. I have been in trouble from past 2 days for import error and could not find a solution

  • @F6GAMEPLAY
    @F6GAMEPLAY 2 года назад +1

    Thanks man, it's a great video for begginers!

    • @masteryst
      @masteryst  2 года назад +1

      You're welcome :). Glad it helps.

  • @nikolaychankov8252
    @nikolaychankov8252 Год назад

    I am getting TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" do ou know what can be the reason ?
    "compilerOptions": {
    "experimentalDecorators": true,
    "lib": ["es2021", "es6", "dom"],
    "module": "commonjs",
    "target": "es2021",
    "allowJs": true,
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "types": ["reflect-metadata", "node", "mocha"],
    "moduleResolution": "node",
    "emitDecoratorMetadata": true
    },
    "include": ["src/**/*", "**/*.spec.ts"],
    "exclude": ["node_modules"]

    • @masteryst
      @masteryst  Год назад

      Hmm.. I never get that error. But maybe you're not installing typescript yet? Sorry for just replying. I can't maintain the youtube for now..

  • @sriharichandanamummaneni
    @sriharichandanamummaneni Год назад

    Im getting ===
    > mocha -r ts-node/register src/test/*.spec.ts --reporter mochawesome --reporter-options reportDir=test-results
    TSError: ⨯ Unable to compile TypeScript:
    src/service/orderService.ts:103:7 - error TS6133: 'discountTypeEnum' is declared but its value is never read.
    ====
    Can anyone help me here.
    Im trying to setup Mocha with typescript

    • @masteryst
      @masteryst  Год назад

      Hi! That error is just because of your lint has setting if the variable, enum or something didn't used, then give error message. So, if you're not setting the discountTypeEnum, just remove it till you need to use it :).
      Or you can read this, and just remove the lint config that is source of your problem.
      www.folkstalk.com/2022/09/eslint-no-unused-vars-typescript-with-code-examples.html

    • @sriharichandanamummaneni
      @sriharichandanamummaneni Год назад

      @@masteryst Thanks for responding. But it's not working. The issue is not something with ESlint config. Can you plz suggest any other one.
      Thanks in advance

    • @masteryst
      @masteryst  Год назад

      @@sriharichandanamummaneni Hi! Oh my.. I am really really sorry, I don't know why but there's no notification on this comment, so I didn't know..
      'discountTypeEnum' is declared but its value is never read.

    • @MANZARBEITIA
      @MANZARBEITIA Год назад

      Hi @sriharichandanamummaneni have you been able to make work mochawesome with Typescript? When I execute the command:
      "test": "set TS_NODE_COMPILER_OPTIONS={\"module\": \"commonjs\"} && mocha --require ts-node/register ./tests/**/*.spec.ts --reporter mochawesome --reporter-options reportDir=test-results"
      In the html created, I don't see TS code, only compiled JS code.
      Thanks in advice.