Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Testing with Babel-Jest聽#4

Open

Description

This example is a great start towards equalizing the usage of TS and Flow for type checking and allowing the integration of TS into Babel projects 馃帀 Kudos 馃憤

I am however having issues with integrating Jest tests into this setup. With TS I would normally use ts-jest, however now that the compilation is being handled by Babel I would think I would need babel-jest so I could run the tests against the Babel output and not the TSC output as I'll be deploying the Babel output, not TSC.

Are there plans to expand this example to include Babel-Jest or is that beyond the scope of this example? If so, has anyone tried this yet and have any pointers?

If this is the right place for the discussion I will update this issue with terminal logs etc.

Activity

  1. DanielRosenwasser commented on Mar 7, 2018

    @DanielRosenwasser
    Member

    Hey James Hegedus (@jthegedus), thanks for the kudos 馃槂. Recently I've not been able to run through that scenario. I may try it out in the future, and if it is relatively simple to explain, we may consider adding it to the starter/walkthrough.

    We're also open to taking PRs, or if you or someone else have a set of steps, we could adapt that to the starter.

  2. jthegedus commented on Mar 7, 2018

    @jthegedus
    Author

    I've been trying. If I get something to work I will certainly PR it for discussion here 馃憤

  3. DanielRosenwasser commented on Mar 7, 2018

    @DanielRosenwasser
    Member
  4. jthegedus commented on Mar 7, 2018

    @jthegedus
    Author

    Ooh, thanks, that covers almost everything I was after I was after.

    Feel free to close this unless you would still like to cover that scenario in this code.

  5. jy95 commented on Apr 10, 2018

    @jy95

    In my case, Jest/ts-Jest doesn't seem to like my declaration only introduced by TypeScript 2.8 (demo repo : https://github.com/jy95/mediaScan/tree/prettier )

    Logs : https://travis-ci.org/jy95/mediaScan/jobs/364394183#L529

    Debug Failure. False expression: Output generation failed
          
          at Object.transpileModule (node_modules/typescript/lib/typescript.js:93386:18)
          at process (node_modules/ts-jest/dist/preprocessor.js:27:28)
          at Object.process (node_modules/ts-jest/index.js:8:51)
    

    tsconfig.json :

    {
      "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "module": "commonjs",
        "target": "es5",
        "lib": ["ES6","ES2017","ESNext"],
        "downlevelIteration": true,
        "moduleResolution": "node",
        "declaration": true,
        "emitDeclarationOnly": true,
        "declarationDir": "./lib"
      },
      "exclude": [
        "node_modules"
      ],
      "include": [
        "src/**/*"
      ],
      "strict": true
    }
    

    jest.config.js :

    // jest.config.js
    module.exports = {
        verbose: true,
        "moduleFileExtensions": [
            "ts",
            "tsx",
            "js"
        ],
        "transform": {
            "^.+\\.tsx?$": "ts-jest"
        },
        "testMatch": [
            "<rootDir>/__tests__/**/*.(ts|tsx|js)"
        ],
        "testPathIgnorePatterns": ["<rootDir>/node_modules/", "<rootDir>/__tests__/__helpers__/"],
        "collectCoverage": true
    };
    

    It seems these guys eat some .d.ts when they are doing the moduleFileExtensions search...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions