pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.61k stars 344 forks source link

Pact.js issue with wrapper code #155

Closed Pingudiem closed 6 years ago

Pingudiem commented 6 years ago

I am testing an interface and use pact to get my descirption up to pact-broker.

My interface is working as planned with the now existing service, but my pact-mock is not working anymore.

Since the last updates I get the following error. I was guessing it had to do with the new zone.js update but I have read that it should no longer be an issue.

TypeError: Cannot read property 'run' of null at at UserContext. node_modules/zone.js/dist/jasmine-patch.js:106:1) at at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:421:1) at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask node_modules/zone.js/dist/zone.js:188:1) at drainMicroTaskQueue node_modules/zone.js/dist/zone.js:595:1) at TypeError: Cannot read property 'run' of null at at UserContext. node_modules/zone.js/dist/jasmine-patch.js:106:1) at at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:421:1) at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask node_modules/zone.js/dist/zone.js:188:1) at drainMicroTaskQueue node_modules/zone.js/dist/zone.js:595:1) at TypeError: Cannot read property 'run' of null at at UserContext. node_modules/zone.js/dist/jasmine-patch.js:104:1) at at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:421:1) at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask node_modules/zone.js/dist/zone.js:188:1) at drainMicroTaskQueue node_modules/zone.js/dist/zone.js:595:1) at TypeError: Cannot read property 'run' of null at at UserContext. node_modules/zone.js/dist/jasmine-patch.js:104:1) at at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:421:1) at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask node_modules/zone.js/dist/zone.js:188:1) at drainMicroTaskQueue node_modules/zone.js/dist/zone.js:595:1) at

"dependencies": { "": "^5.2.3", "": "^5.2.3", "": "^5.2.3", "": "^5.2.3", "": "^5.2.3", "": "^5.2.3", "": "^5.2.3", "": "^5.2.3", "": "^5.2.3", "core-js": "^2.4.1", "jasmine": "^3.0.0", "ncu": "^0.2.1", "rxjs": "^5.5.6", "zone": "^0.3.4", "zone.js": "^0.8.19" }, "devDependencies": { "": "^1.7.1", "": "^5.2.6", "": "^5.2.6", "@pact-foundation/karma-pact": "2.1.5", "@pact-foundation/pact-node": "6.10.0", "@pact-foundation/pact-web": "5.6.1", "": "^2.8.6", "": "~2.0.2", "": "~9.4.1", "codelyzer": "^4.0.1", "cross-env": "^5.0.5", "jasmine-core": "~3.0.0", "jasmine-spec-reporter": "~4.2.1", "karma": "^2.0.0", "karma-chrome-launcher": "~2.2.0", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.3.0", "ts-node": "~5.0.0", "tslint": "^5.9.1", "typescript": "^2.7.2" } }

Is that still an Zone issue or is it on your side?

thank you!

mefellows commented 6 years ago

Thanks @Pingudiem , do you have an example setup we can use to reproduce your problem? The CONTRIBUTING guidelines have some questions in there, do you mind please filling those in for us too?

I'm not aware of that being an issue.

Pingudiem commented 6 years ago

Software versions

"private": true, "dependencies": { "@angular/animations": "^5.2.3", "@angular/common": "^5.2.3", "@angular/compiler": "^5.2.3", "@angular/core": "^5.2.3", "@angular/forms": "^5.2.3", "@angular/http": "^5.2.3", "@angular/platform-browser": "^5.2.3", "@angular/platform-browser-dynamic": "^5.2.3", "@angular/router": "^5.2.3", "core-js": "^2.4.1", "jasmine": "^3.0.0", "ncu": "^0.2.1", "rxjs": "^5.5.6", "zone": "^0.3.4", "zone.js": "^0.8.19" }, "devDependencies": { "@angular/cli": "^1.7.1", "@angular/compiler-cli": "^5.2.6", "@angular/language-service": "^5.2.6", "@pact-foundation/karma-pact": "2.1.5", "@pact-foundation/pact-node": "6.10.0", "@pact-foundation/pact-web": "5.6.1", "@types/jasmine": "^2.8.6", "@types/jasminewd2": "~2.0.2", "@types/node": "~9.4.1", "codelyzer": "^4.0.1", "cross-env": "^5.0.5", "jasmine-core": "~3.0.0", "jasmine-spec-reporter": "~4.2.1", "karma": "^2.0.0", "karma-chrome-launcher": "~2.2.0", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.3.0", "ts-node": "~5.0.0", "tslint": "^5.9.1", "typescript": "^2.7.2" }

Expected behaviour

I want my tests to start a pact-mock server, fill it with interface options predefined and testing my service.

Actual behaviour

Mock-server starts, karma and jasmine start appearing and then idle around.

Steps to reproduce

Relevant log files

01 03 2018 08:57:08.221:DEBUG [config]: Loading config /home/Philip/Develop/Git/smit-umzugsmeldung/karma.conf.js
01 03 2018 08:57:08.225:DEBUG [plugin]: Loading inlined plugin (defining framework:jasmine).
01 03 2018 08:57:08.225:DEBUG [plugin]: Loading inlined plugin (defining framework:pact).
01 03 2018 08:57:08.225:DEBUG [plugin]: Loading inlined plugin (defining launcher:Chrome, launcher:ChromeHeadless, launcher:ChromeCanary, launcher:ChromeCanaryHeadless, launcher:Chromium, launcher:ChromiumHeadless, launcher:Dartium, test).
01 03 2018 08:57:08.225:DEBUG [plugin]: Loading inlined plugin (defining reporter:kjhtml).
01 03 2018 08:57:08.225:DEBUG [plugin]: Loading inlined plugin (defining reporter:coverage-istanbul).
01 03 2018 08:57:08.225:DEBUG [plugin]: Loading inlined plugin (defining framework:@angular/cli, preprocessor:@angular/cli, reporter:@angular/cli, middleware:angularCliBlocker).
 10% building modules 1/1 modules 0 active[2018-03-01T07:57:08.359Z]  INFO: pact-node@6.10.0/3913 on pd-unix:
    Creating Pact Server with options:
    cors = true,
    port = 8081,
    consumer = MoveMessageUI,
    provider = ContactService,
    dir = /home/Philip/Develop/Git/smit-umzugsmeldung/pacts,
    spec = 2,
    pactFileWriteMode = overwrite,
    ssl = false,
    host = localhost
[2018-03-01T07:57:08.370Z]  INFO: pact-node@6.10.0/3913 on pd-unix: Created './platforms/linux-x64/bin/pact-mock-service service --cors 'true' --port '8081' --consumer 'MoveMessageUI' --provider 'ContactService' --pact_dir '/home/Philip/Develop/Git/smit-umzugsmeldung/pacts' --pact_specification_version '2' --pact-file-write-mode 'overwrite' --host 'localhost'' process with PID: 3930
01 03 2018 08:57:10.774:INFO [pact]: Pact Mock Server running on port: 8081
01 03 2018 08:57:10.779:DEBUG [web-server]: Instantiating middleware
01 03 2018 08:57:10.780:DEBUG [reporter]: Trying to load reporter: @angular/cli
01 03 2018 08:57:10.780:DEBUG [reporter]: Trying to load color-version of reporter: @angular/cli (@angular/cli_color)
01 03 2018 08:57:10.780:DEBUG [reporter]: Couldn't load color-version.
01 03 2018 08:57:10.788:DEBUG [reporter]: Trying to load reporter: kjhtml
01 03 2018 08:57:10.788:DEBUG [reporter]: Trying to load color-version of reporter: kjhtml (kjhtml_color)
01 03 2018 08:57:10.789:DEBUG [reporter]: Couldn't load color-version.
01 03 2018 08:57:10.807:DEBUG [karma]: List of files has changed, trying to execute
01 03 2018 08:57:10.807:WARN [karma]: No captured browser, open http://localhost:8080/
01 03 2018 08:57:10.810:DEBUG [watcher]: Watching "/home/Philip/Develop/Git/smit-umzugsmeldung/src/favicon.ico"
01 03 2018 08:57:10.811:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:8080/
01 03 2018 08:57:10.811:INFO [launcher]: Launching browser Chrome with unlimited concurrency
01 03 2018 08:57:10.815:INFO [launcher]: Starting browser Chrome
01 03 2018 08:57:10.815:DEBUG [temp-dir]: Creating temp dir at /tmp/karma-62190918
01 03 2018 08:57:10.816:DEBUG [launcher]: google-chrome --user-data-dir=/tmp/karma-62190918 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications http://localhost:8080/?id=62190918
01 03 2018 08:57:14.223:DEBUG [web-server]: serving: /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma/static/client.html
01 03 2018 08:57:14.227:DEBUG [karma]: List of files has changed, trying to execute
01 03 2018 08:57:14.227:WARN [karma]: No captured browser, open http://localhost:8080/
01 03 2018 08:57:14.233:DEBUG [web-server]: serving: /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma/static/karma.js
01 03 2018 08:57:14.350:DEBUG [karma]: A browser has connected on socket 53k7osWUUXOYA-oxAAAA
01 03 2018 08:57:14.379:INFO [Chrome 64.0.3282 (Linux 0.0.0)]: Connected on socket 53k7osWUUXOYA-oxAAAA with id 62190918
01 03 2018 08:57:14.379:DEBUG [launcher]: Chrome (id 62190918) captured in 3.568 secs
01 03 2018 08:57:14.379:DEBUG [karma]: All browsers are ready, executing
01 03 2018 08:57:14.380:DEBUG [karma]: Captured 1 browsers
01 03 2018 08:57:14.380:DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=53k7osWUUXOYA-oxAAAA
01 03 2018 08:57:14.380:DEBUG [proxy]: NOT upgrading proxyWebSocketRequest /socket.io/?EIO=3&transport=websocket&sid=53k7osWUUXOYA-oxAAAA
01 03 2018 08:57:14.383:DEBUG [web-server]: serving: /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma/static/favicon.ico
01 03 2018 08:57:14.389:DEBUG [middleware:karma]: custom files /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/@angular/cli/plugins/karma-context.html /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/@angular/cli/plugins/karma-debug.html null
01 03 2018 08:57:14.389:DEBUG [middleware:karma]: Serving customContextFile /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/@angular/cli/plugins/karma-context.html
01 03 2018 08:57:14.390:DEBUG [web-server]: serving: /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/@angular/cli/plugins/karma-context.html
01 03 2018 08:57:14.394:DEBUG [web-server]: serving: /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma/static/context.js
01 03 2018 08:57:14.396:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/inline.bundle.js /
01 03 2018 08:57:14.397:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/inline.bundle.js
01 03 2018 08:57:14.399:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/polyfills.bundle.js /
01 03 2018 08:57:14.400:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/polyfills.bundle.js
01 03 2018 08:57:14.400:DEBUG [middleware:source-files]: Requesting /base/node_modules/source-map-support/browser-source-map-support.js?3a3db3887ab08eb10eb5bdd356db8d254e26effa /
01 03 2018 08:57:14.401:DEBUG [middleware:source-files]: Fetching /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/source-map-support/browser-source-map-support.js
01 03 2018 08:57:14.401:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-source-map-support/lib/client.js?fcb459e84379f1ce8e91fe200d87463f3780ca1b /
01 03 2018 08:57:14.402:DEBUG [middleware:source-files]: Fetching /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-source-map-support/lib/client.js
01 03 2018 08:57:14.402:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-jasmine-html-reporter/src/css/jasmine.css?c9871b8538297ee2479a3223e4b1c8afaa94e162 /
01 03 2018 08:57:14.403:DEBUG [middleware:source-files]: Fetching /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine-html-reporter/src/css/jasmine.css
01 03 2018 08:57:14.404:DEBUG [web-server]: serving (cached): /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/source-map-support/browser-source-map-support.js
01 03 2018 08:57:14.404:DEBUG [web-server]: serving (cached): /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-source-map-support/lib/client.js
01 03 2018 08:57:14.405:DEBUG [web-server]: serving (cached): /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine-html-reporter/src/css/jasmine.css
01 03 2018 08:57:14.406:DEBUG [middleware:source-files]: Requesting /base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?8274d58828bfa8f0e866585404896e1e94f2fa07 /
01 03 2018 08:57:14.406:DEBUG [middleware:source-files]: Fetching /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
01 03 2018 08:57:14.406:DEBUG [web-server]: serving (cached): /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
01 03 2018 08:57:14.407:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-jasmine/lib/boot.js?945a38bf4e45ad2770eb94868231905a04a0bd3e /
01 03 2018 08:57:14.407:DEBUG [middleware:source-files]: Fetching /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine/lib/boot.js
01 03 2018 08:57:14.408:DEBUG [web-server]: serving (cached): /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine/lib/boot.js
01 03 2018 08:57:14.408:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-jasmine/lib/adapter.js?3e6cdea3167f037eeb11034f8eb9ce63b21a8105 /
01 03 2018 08:57:14.408:DEBUG [middleware:source-files]: Fetching /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine/lib/adapter.js
01 03 2018 08:57:14.409:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-jasmine-html-reporter/src/lib/html.jasmine.reporter.js?4af523ab7bfaa86c4966fa332c4dc2bd2278b4cc /
01 03 2018 08:57:14.409:DEBUG [middleware:source-files]: Fetching /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine-html-reporter/src/lib/html.jasmine.reporter.js
01 03 2018 08:57:14.410:DEBUG [web-server]: serving (cached): /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine/lib/adapter.js
01 03 2018 08:57:14.410:DEBUG [web-server]: serving (cached): /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine-html-reporter/src/lib/html.jasmine.reporter.js
01 03 2018 08:57:14.410:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-jasmine-html-reporter/src/lib/adapter.js?9d2c71b931979c6194d209809111ee3a72cf149b /
01 03 2018 08:57:14.410:DEBUG [middleware:source-files]: Fetching /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine-html-reporter/src/lib/adapter.js
01 03 2018 08:57:14.411:DEBUG [web-server]: serving (cached): /home/Philip/Develop/Git/smit-umzugsmeldung/node_modules/karma-jasmine-html-reporter/src/lib/adapter.js
01 03 2018 08:57:14.412:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/scripts.bundle.js /
01 03 2018 08:57:14.412:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/scripts.bundle.js
01 03 2018 08:57:14.413:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/vendor.bundle.js /
01 03 2018 08:57:14.414:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/vendor.bundle.js
01 03 2018 08:57:14.414:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/main.bundle.js /
01 03 2018 08:57:14.414:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/main.bundle.js
01 03 2018 08:57:14.651:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/vendor.bundle.js /
01 03 2018 08:57:14.651:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/vendor.bundle.js
01 03 2018 08:57:14.692:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/vendor.bundle.js /
01 03 2018 08:57:14.692:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/vendor.bundle.js
01 03 2018 08:57:15.644:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/inline.bundle.js /
01 03 2018 08:57:15.644:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/inline.bundle.js
01 03 2018 08:57:15.645:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/inline.bundle.js /
01 03 2018 08:57:15.646:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/inline.bundle.js
01 03 2018 08:57:15.661:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/main.bundle.js /
01 03 2018 08:57:15.662:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/main.bundle.js
01 03 2018 08:57:15.664:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/main.bundle.js /
01 03 2018 08:57:15.664:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/main.bundle.js
Chrome 64.0.3282 (Linux 0.0.0): Executed 0 of 3 SUCCESS (0 secs / 0 secs)
01 03 2018 08:57:17.735:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/polyfills.bundle.js /
01 03 2018 08:57:17.735:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/polyfills.bundle.js
01 03 2018 08:57:17.741:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/polyfills.bundle.js /
Chrome 64.0.3282 (Linux 0.0.0) ContactServiceClient sendMoveMessage() should send an MoveMessage  FAILED
        TypeError: Cannot read property 'run' of null
            at <Jasmine>
            at UserContext.<anonymous> node_modules/zone.js/dist/jasmine-patch.js:106:1)
            at <Jasmine>
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:421:1)
            at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask node_modules/zone.js/dist/zone.js:188:1)
            at drainMicroTaskQueue node_modules/zone.js/dist/zone.js:595:1)
            at <Jasmine>
        TypeError: Cannot read property 'run' of null
            at <Jasmine>
            at UserContext.<anonymous> node_modules/zone.js/dist/jasmine-patch.js:106:1)
            at <Jasmine>
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:421:1)
            at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask node_modules/zone.js/dist/zone.js:188:1)
            at drainMicroTaskQueue node_modules/zone.js/dist/zone.js:595:1)
            at <Jasmine>
        TypeError: Cannot read property 'run' of null
            at <Jasmine>
            at UserContext.<anonymous> node_modules/zone.js/dist/jasmine-patch.js:104:1)
            at <Jasmine>
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:421:1)
            at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask node_modules/zone.js/dist/zone.js:188:1)
            at drainMicroTaskQueue node_modules/zone.js/dist/zone.js:595:1)
            at <Jasmine>
        TypeError: Cannot read property 'run' of null
            at <Jasmine>
            at UserContext.<anonymous> node_modules/zone.js/dist/jasmine-patch.js:104:1)
            at <Jasmine>
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:421:1)
            at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask node_modules/zone.js/dist/zone.js:188:1)
            at drainMicroTaskQueue node_modules/zone.js/dist/zone.js:595:1)
            at <Jasmine>
Chrome 64.0.3282 (Linux 0.0.0): Executed 1 of 3 (1 FAILED) (0 secs / 0 secs)
mefellows commented 6 years ago

Thanks @Pingudiem, unfortunately that's not enough for us to be able to reproduce. Do you have a code example we can use to reliably reproduce the problem?

Specificalyl, the test for ContactServiceClient sendMoveMessage() should send an MoveMessage which is the first failure if I'm understanding correctly.

Pingudiem commented 6 years ago

`import { TestBed } from '@angular/core/testing'; import { HttpClientModule } from '@angular/common/http'; import { ContactServiceClient } from './app.data.client'; import { Address } from './app.address'; import { PactWeb, Matchers } from '@pact-foundation/pact-web'; import { MoveMessage } from './app.movemessage'; import { Contact } from './app.contact';

// Test Variable const id = '4711';

describe('ContactServiceClient', () => {

let provider;

beforeAll(function (done) {
    provider = new PactWeb({
        consumer: 'MoveMessageUI',
        provider: 'ContactService',
        port: 8081,
        host: '127.0.0.1'
    });
    // required for slower CI environments
    setTimeout(done, 2000);

    // Required if run with `singleRun: false`
    provider.removeInteractions();
});

afterAll(function (done) {
    provider.finalize()
        .then(function () {
            done();
        }, function (err) {
            done.fail(err);
        });
});

beforeEach(() => {
    TestBed.configureTestingModule({
        imports: [
            HttpClientModule
        ],
        providers: [
            ContactServiceClient
        ],
    });
});

afterEach((done) => {
    provider.verify().then(done, e => done.fail(e));
});

describe('sendMoveMessage()', () => {

    const expectedMoveMessage: MoveMessage = {
        street: 'Musterstrasse',
        number: '1a',
        zipCode: '100',
        city: 'Musterhausen',
        countryCode: 'DE',
        validFrom: '01.01.2019',
        clientId: '4711'
    };

    beforeAll((done) => {
        provider.addInteraction({
            state: `contact with Id 4711 exists`,
            uponReceiving: 'a request to POST a movemessage',
            withRequest: {
                method: 'POST',
                path: '/contacts/4711/movemessage',
                body: expectedMoveMessage,
                headers: {
                    'Content-Type': 'application/json',
                    'clientId': ''
                }
            },
            willRespondWith: {
                status: 201
            }
        }).then(done, error => done.fail(error));
    });

    it('should send an MoveMessage ', (done) => {
        const contactServiceClient: ContactServiceClient = TestBed.get(ContactServiceClient);
        contactServiceClient.sendMoveMessage(expectedMoveMessage).then(response => {
            done();
        }, error => {
            done.fail(error);
        });
    });

});

});`

sendMoveMessage(movemessage: MoveMessage): Promise<MoveMessage> { return this.http.post(this.contactUrl + '/' + this.contactID + '/movemessage', movemessage, { headers: this.headers }) .toPromise() .then(response => response as MoveMessage) .catch(this.handleError); }

This is the test and the function that is tested.

module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', '@angular/cli', 'pact'], plugins: [ require('karma-jasmine'), require('@pact-foundation/karma-pact'), require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'), require('@angular/cli/plugins/karma'), ], client: { clearContext: false // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { reports: ['html', 'lcovonly'], fixWebpackSourcePaths: true }, angularCli: { environment: 'dev' }, reporters: ['progress', 'kjhtml'], port: 8080, colors: true, logLevel: config.LOG_DEBUG, autoWatch: true, browsers: ['Chrome'], singleRun: false, pact: [{ cors: true, port: 8081, consumer: "MoveMessageUI", provider: "ContactService", dir: "pacts", spec: 2 }], proxies: { '/contacts/': 'http://127.0.0.1:8081/contacts/' } }); };

this is my Karma.conf

Hope this helps reproduce the problem.

mefellows commented 6 years ago

Thanks @Pingudiem. Is there any chance you could post a minimal repository that reproduces the issue? Unfortunately what you've provided is not enough - what versions of software are you using, how can we run it etc. etc.

We need to be able to reproduce the issue, which we can't do with the above.

Also, as a side note, you could simplify the following

    provider = new PactWeb({
        consumer: 'MoveMessageUI',
        provider: 'ContactService',
        port: 8081,
        host: '127.0.0.1'
    });
    // required for slower CI environments
    setTimeout(done, 2000);

    // Required if run with `singleRun: false`
    provider.removeInteractions();
});

afterAll(function (done) {
    provider.finalize()
        .then(function () {
            done();
        }, function (err) {
            done.fail(err);
        });
});

with...

beforeAll(() => provider.removeInteractions());
afterAll(() => provider.finalize());
Pingudiem commented 6 years ago

pact_test_repo.zip

Zipped a test case closely to my program.

To reproduce the issue: npm install ng test

Now you should encounter the above stated log where the issue comes up.

Thank you.

mefellows commented 6 years ago

I removed all pact stuff and that issue still happens, so I'm fairly certain it's not pact related, given all of the errors are zone and jasmine looking. See the following for references to this problem:

If you update package.json as per the thread as follows, your tests run (but fail due to other problems with the test, which should be straightforward to fix): "zone.js": "git://github.com/JiaLiPassion/zone.js#jasmine-dist".

Closing, as this is not an issue with Pact.