kulshekhar / ts-jest

A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript.
https://kulshekhar.github.io/ts-jest
MIT License
6.93k stars 453 forks source link

Cannot import *.d.ts from module #538

Closed pyoner closed 6 years ago

pyoner commented 6 years ago

Types should be imported

vue-firebase-plugin@0.0.0-development test /home/jungle/repo/vue-firebase-plugin jest --debug

{ "configs": [ { "automock": false, "browser": false, "cache": true, "cacheDirectory": "/tmp/jungle/jest_rs", "clearMocks": false, "coveragePathIgnorePatterns": [ "/node_modules/", "/test/" ], "detectLeaks": false, "forceCoverageMatch": [], "globals": { "ts-jest": { "tsConfigFile": "tsconfig.jest.json" } }, "haste": { "providesModuleNodeModules": [] }, "moduleDirectories": [ "node_modules" ], "moduleFileExtensions": [ "ts", "tsx", "js" ], "moduleNameMapper": {}, "modulePathIgnorePatterns": [], "name": "1783d1d0b16c3cb9fb9c25becff38ac8", "resetMocks": false, "resetModules": false, "restoreMocks": false, "rootDir": "/home/jungle/repo/vue-firebase-plugin", "roots": [ "/home/jungle/repo/vue-firebase-plugin" ], "runner": "jest-runner", "setupFiles": [], "snapshotSerializers": [], "testEnvironment": "jest-environment-jsdom", "testEnvironmentOptions": {}, "testLocationInResults": false, "testMatch": [], "testPathIgnorePatterns": [ "/node_modules/" ], "testRegex": "(/tests/.*|\.(test|spec))\.(ts|tsx|js)$", "testRunner": "/home/jungle/repo/vue-firebase-plugin/node_modules/jest/node_modules/jest-jasmine2/build/index.js", "testURL": "about:blank", "timers": "real", "transform": [ [ "^.+\.tsx?$", "/home/jungle/repo/vue-firebase-plugin/node_modules/ts-jest/index.js" ] ], "transformIgnorePatterns": [ "/node_modules/" ], "watchPathIgnorePatterns": [] } ], "globalConfig": { "bail": false, "changedFilesWithAncestor": false, "collectCoverage": true, "coverageDirectory": "/home/jungle/repo/vue-firebase-plugin/coverage", "coverageReporters": [ "json", "text", "lcov", "clover" ], "coverageThreshold": { "global": { "branches": 90, "functions": 95, "lines": 95, "statements": 95 } }, "detectLeaks": false, "expand": false, "globalSetup": null, "globalTeardown": null, "listTests": false, "maxWorkers": 3, "noStackTrace": false, "nonFlagArgs": [], "notify": false, "notifyMode": "always", "passWithNoTests": false, "rootDir": "/home/jungle/repo/vue-firebase-plugin", "runTestsByPath": false, "testFailureExitCode": 1, "testPathPattern": "", "testResultsProcessor": null, "updateSnapshot": "new", "useStderr": false, "verbose": null, "watch": false, "watchman": true }, "version": "22.4.2" } FAIL test/vue-firebase-plugin.test.ts ● Test suite failed to run

Cannot find module '@firebase/firestore-types' from 'Firestore.ts'

  17 |   StartEnd,
  18 |   CreateRef
> 19 | } from '../utils'
  20 | 
  21 | interface Inner {
  22 |   unsubscribe?: () => void

  at Resolver.resolveModule (node_modules/jest/node_modules/jest-resolve/build/index.js:169:17)
  at Object.<anonymous> (src/components/Firestore.ts:19:49)

FAIL test/Firestore.test.ts ● Test suite failed to run

Cannot find module '@firebase/firestore-types' from 'Firestore.ts'

  17 |   StartEnd,
  18 |   CreateRef
> 19 | } from '../utils'
  20 | 
  21 | interface Inner {
  22 |   unsubscribe?: () => void

  at Resolver.resolveModule (node_modules/jest/node_modules/jest-resolve/build/index.js:169:17)
  at Object.<anonymous> (src/components/Firestore.ts:19:49)

FAIL test/utils.test.ts ● Test suite failed to run

Cannot find module '@firebase/firestore-types' from 'utils.ts'

  88 |     return value.toDate()
  89 |   }
> 90 | 
  91 |   if (value instanceof GeoPoint) {
  92 |     return {
  93 |       latitude: value.latitude,

  at Resolver.resolveModule (node_modules/jest/node_modules/jest-resolve/build/index.js:169:17)
  at Object.<anonymous> (src/utils.ts:90:284)
---------- ---------- ---------- ---------- ---------- ---------------- File % Stmts % Branch % Funcs % Lines Uncovered Lines
All files Unknown Unknown Unknown Unknown
---------- ---------- ---------- ---------- ---------- ----------------

Jest: Coverage data for global was not found. Test Suites: 3 failed, 3 total Tests: 0 total Snapshots: 0 total Time: 4.429s Ran all test suites. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! vue-firebase-plugin@0.0.0-development test: jest --debug npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the vue-firebase-plugin@0.0.0-development test script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/jungle/.npm/_logs/2018-05-22T09_52_22_848Z-debug.log



- Link to a minimal repo that reproduces this issue

Here my repo https://github.com/pyoner/vue-firebase-plugin

- Optional (but highly recommended) - Configure Travis (or your favorite system) with the minimal repo

https://travis-ci.org/pyoner/vue-firebase-plugin/jobs/382075803
pyoner commented 6 years ago

I think it's not jest issue It's firebase issue https://github.com/firebase/firebase-js-sdk/issues/767

GeeWee commented 6 years ago

Nicely discovered. Closing.