Closed Pien1991 closed 6 years ago
Did I npm install correctly ?
Did you mean @pact-foundation/pact
?
Also, you might want to read https://github.com/pact-foundation/pact-js/#using-pact-in-non-node-environments
When I use Webstorm IDE to read @pact-foundation/pact code , the IDE point out that inside options.d.ts , it cannot find module 'pact' for importing MeesageProviders and StateHandlers .
Which could be the reason ? Or Am I missing any dependency package ?
My Angular version :
Angluar CLI version : 6.2.5 Node: 9.7.1 Angular: 6.1.10
@angular-devkit/architect 0.8.5 @angular-devkit/build-angular 0.8.5 @angular-devkit/build-optimizer 0.8.5 @angular-devkit/build-webpack 0.8.5 @angular-devkit/core 0.8.5 @angular-devkit/schematics 0.8.5 @angular/cli 6.2.5 @ngtools/webpack 6.2.5 @schematics/angular 0.8.5 @schematics/update 0.8.5 rxjs 6.2.2 typescript 2.9.2 webpack 4.20.2 `
Below is my karma.conf.js
module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', '@angular-devkit/build-angular','pact'], plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'), require('@angular-devkit/build-angular/plugins/karma'), require('@pact-foundation/karma-pact') ], pact: [{ cors: true, port: 1234, consumer: "ui", provider: "user-service", dir: "pactFolder", spec: 2 }], angularCli: { environment: 'dev' }, client: { clearContext: false // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { dir: require('path').join(__dirname, '../coverage'), reports: ['html', 'lcovonly'], fixWebpackSourcePaths: true }, reporters: ['progress', 'kjhtml'], port: 9876, colors: true, logLevel: config.LOG_DEBUG, autoWatch: true, browsers: ['Chrome'], singleRun: false }); };
Hi @Pien1991, I've removed my previous comment as it doesn't apply.
That being said, I believe you might have the wrong dependency.
Please read and take a look at https://github.com/pact-foundation/pact-js/#using-pact-in-non-node-environments if you haven't already. There is a section there that might be helpful.
You will probably need the @pact-foundation/pact-web
module. I suspect that could be part of the problem.
That being said, the code highlighted does look curious and i'll look at it shortly.
I try to edit the library provided by pact-foundation and it work perfectly . No error exist anymore . I suspect that could it be tslink.json checking issue ?
Yes, I made a similar change locally. I'll try to bisect and find out when that issue crept in. I don't want to rush it out, because the build/test system should have picked this up. Thanks for drawing attention to it.
You welcome ~ . I am doing a demo for my team , try to use pact-js and pact-jvm with pact broker . If it is fixed , our team will use pact for contract test .
Software versions
Expected behaviour
Using Karma to perform contract test and generate contract . No webpack built error message should exist .
Actual behaviour
Pact js installed by npm correctly. Using 'ng test' to do unit test for Angular app. During the webpack built time , error message exist : "ERROR in node_modules/@pact-foundation/pact/dsl/options.d.ts(6,49): error TS2307: Cannot find module 'pact'."
Steps to reproduce
Using 'ng test'
Relevant log files
Version: webpack 4.20.2
Time: 4220ms Built at: 10/12/2018 10:50:39 AM Asset Size Chunks Chunk Names main.js 3.77 KiB main main polyfills.js 4.17 KiB polyfills polyfills styles.js 8.13 KiB styles styles vendor.js 14.7 KiB vendor vendor Entrypoint main = main.js Entrypoint polyfills = polyfills.js Entrypoint styles = vendor.js styles.js [./node_modules/raw-loader/index.js!./node_modules/postcss-loader/lib/index.js?!./src/styles.css] ./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./src/styles.css 100 bytes {styles} [built] [./node_modules/style-loader/lib/addStyles.js] 9.77 KiB {vendor} [built] [./node_modules/style-loader/lib/urls.js] 2.94 KiB {vendor} [built] [./src/polyfills.ts] 0 bytes {polyfills} [built] [./src/styles.css] 1.21 KiB {styles} [built] [0] multi ./src/polyfills.ts 28 bytes {polyfills} [built] [1] multi ./src/styles.css 28 bytes {styles} [built] [./src/test.ts] 0 bytes {main} [built]
ERROR in node_modules/@pact-foundation/pact/dsl/options.d.ts(6,49): error TS2307: Cannot find module 'pact'.
12 10 2018 10:51:05.633:ERROR [pact]: Error while trying to run karma-pact: Error: Couldn't start Pact with PID: 5964