Xiaofeng Xie
09/08/2022, 4:22 AMpino is not a function error?
TypeError: pino is not a function
at Object.createLogger(../../node_modules/@pact-foundation/pact-core/src/logger/pino.ts
at Object.createLogger(../../node_modules/@pact-foundation/pact-core/src/logger/index.ts
at Object.createLogger(../../node_modules/@pact-foundation/pact-core/src/service.ts
I got this error when I tried to do
const provider = new PactV3({consumer:"foo",provider:"bar"});Timothy Jones
09/08/2022, 4:31 AMXiaofeng Xie
09/08/2022, 4:48 AMjest: 28.1.3
@pact-foundation/pact: 10.1.3
typescript: 4.8.2
ts-jest:28.0.8
@types/jest: 28.1.3Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Xiaofeng Xie
09/08/2022, 4:52 AMXiaofeng Xie
09/08/2022, 4:52 AMMatt (pactflow.io / pact-js / pact-go)
Xiaofeng Xie
09/08/2022, 4:53 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Xiaofeng Xie
09/08/2022, 4:56 AMXiaofeng Xie
09/08/2022, 4:57 AMMatt (pactflow.io / pact-js / pact-go)
Timothy Jones
09/08/2022, 5:04 AM../../ - are you installing your node_modules somewhere custom? Are you running your tests from a non-root directory?Timothy Jones
09/08/2022, 5:04 AMTimothy Jones
09/08/2022, 5:06 AMXiaofeng Xie
09/08/2022, 5:06 AMfolder structure
my-project
-node_modules
-src
-__tests__
-mytest.pact.tsTimothy Jones
09/08/2022, 5:08 AMnpm ls pino do?Xiaofeng Xie
09/08/2022, 5:10 AMmodule.exports = {
roots: ['<rootDir>/src'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|(\\.|/))\\.(test|spec|pact)\\.tsx?$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
collectCoverage: true,
collectCoverageFrom: ['src/**/*.ts'],
coveragePathIgnorePatterns: ['index.ts'],
moduleDirectories: ['node_modules', '.', '../../utils'],
coverageThreshold: {
global: {
statements: 80,
},
},
};Xiaofeng Xie
09/08/2022, 5:10 AM{
"compilerOptions": {
"baseUrl": "./",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./dist",
"allowJs": false,
"declaration": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"target": "es2018",
"lib": [
"es2018",
"esnext.asynciterable"
],
"sourceMap": true,
"strict": true,
"strictNullChecks": false,
"paths": {
"src/*": [
"src/*"
]
}
},
"exclude": [
"node_modules"
],
"include": [
"src",
"*.d.ts",
"mocks"
]
}Timothy Jones
09/08/2022, 5:11 AMmoduleDirectories: ['node_modules' <-- node_modules definitely should not be hereTimothy Jones
09/08/2022, 5:11 AM'../../utils' <-- this is also suspicious, since it suggests there's a package above youXiaofeng Xie
09/08/2022, 5:13 AMTimothy Jones
09/08/2022, 5:15 AMTimothy Jones
09/08/2022, 5:15 AMmoduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], <-- change this
moduleFileExtensions: [ 'js', 'jsx', 'ts', 'tsx','json', 'node'], <-- to thisTimothy Jones
09/08/2022, 5:15 AMTimothy Jones
09/08/2022, 5:16 AMTimothy Jones
09/08/2022, 5:17 AMTimothy Jones
09/08/2022, 5:17 AMXiaofeng Xie
09/08/2022, 5:17 AMTimothy Jones
09/08/2022, 5:18 AM.d.ts files are still included of course)Timothy Jones
09/08/2022, 5:18 AMXiaofeng Xie
09/08/2022, 5:20 AMcannot-find-module-source-map-support (probably i can take look at this ) .Timothy Jones
09/08/2022, 5:21 AMajv avoids this problem by putting the compiled files in a dist folder, so imports don't get confusedTimothy Jones
09/08/2022, 5:21 AMTimothy Jones
09/08/2022, 5:21 AMmoduleFileExtensionsXiaofeng Xie
09/08/2022, 5:22 AMXiaofeng Xie
09/08/2022, 5:23 AMTimothy Jones
09/08/2022, 5:31 AMTimothy Jones
09/08/2022, 5:32 AMTimothy Jones
09/08/2022, 5:32 AMXiaofeng Xie
09/08/2022, 5:37 AMXiaofeng Xie
09/08/2022, 6:11 AMXiaofeng Xie
09/08/2022, 6:11 AMXiaofeng Xie
09/08/2022, 6:11 AMTimothy Jones
09/08/2022, 6:12 AMTimothy Jones
09/08/2022, 8:31 AMXiaofeng Xie
09/08/2022, 2:32 PM"." in the moduleDirectories field and that causes the pino failureXiaofeng Xie
09/08/2022, 2:56 PMmodule-alias and the pact packageTimothy Jones
09/09/2022, 12:01 AMTimothy Jones
09/09/2022, 12:04 AMnode_modules is by default blocked from being involved in the transpilation, but reincluded when you include "." in the modules.
Anyway, this isn't a pact problem. It is a problem to do with the strange way that ts-jest is set up in this project.