Sebastian Suarez
03/28/2022, 7:59 PMAdrian Ernst
03/30/2022, 1:03 PMRadha
03/30/2022, 10:06 PMmocha --recursive "tests/*.pact.js" --timeout 100000[2022-03-30T220407.287Z] INFO: pact-node@10.9.4/13532 on PC0X2B10: Creating Pact Server with options: {"consumer":"React","cors":false,"dir":"C:\\UIEN-Local\\pact-test\\pact-test\\pacts","host":"127.0.0.1","log":"C:\\UIEN-Local\\pact-test\\pact-test\\logs\\pact.log","pactFileWriteMode":"overwrite","port":1234,"provider":"token","spec":2,"ssl":false} Consumer Test [2022-03-30T220408.891Z] INFO: pact@9.11.0/13532 on PC0X2B10: Setting up Pact with Consumer "React" and Provider "token" using mock service on Port: "1234" √ OK response Pact verification failed! Actual interactions do not match expected interactions for mock MockService. Missing requests: GET /modules See C:/UIEN-Local/pact-test/pact-test/logs/pact.log for details. (node:13532) UnhandledPromiseRejectionWarning: AssertionError: expected 'OK ' to equal 'OK' at C\UIEN Local\pact test\pact test\tests\consumer.pact.js55:47 at processTicksAndRejections (internal/process/task_queues.js975) (node:13532) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:13532) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
1) "after each" hook for "OK response"
[2022-03-30T220408.973Z] INFO: pact@9.11.0/13532 on PC0X2B10: Pact File Written
[2022-03-30T220408.973Z] INFO: pact-node@10.9.4/13532 on PC0X2B10: Removing Pact process with PID: 9936
[2022-03-30T220409.152Z] INFO: pact-node@10.9.4/13532 on PC0X2B10:
Deleting Pact Server with options:
{"consumer":"React","cors":false,"dir":"C:\\UIEN-Local\\pact-test\\pact-test\\pacts","host":"127.0.0.1","log":"C:\\UIEN-Local\\pact-test\\pact-test\\logs\\pact.log","pactFileWriteMode":"overwrite","port":1234,"provider":"token","spec":2,"ssl":false}
1 passing (2s)
1 failing
1) Consumer Test
"after each" hook for "OK response":
Error: Pact verification failed - expected interactions did not match actual.
at new VerificationError (node_modules\@pact-foundation\pact\errors\verificationError.js1942)
at C:\UIEN-Local\pact-test\pact-test\node_modules\@pact-foundation\pact\httpPact.js10223
at processTicksAndRejections (internal/process/task_queues.js975)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! consumer@1.0.0 pacts: mocha --recursive "tests/*.pact.js" --timeout 100000
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the consumer@1.0.0 pacts 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! C:\Users\radha.danthuluri\AppData\Roaming\npm-cache\_logs\2022-03-30T22_04_09_197Z-debug.logGitHub
04/01/2022, 7:24 AMAlan Alie
04/01/2022, 10:09 AMimport { URL } from 'url';
import { Matchers } from '@pact-foundation/pact';
import { HTTPMethod } from '@pact-foundation/pact/src/common/request';
import { pactWith } from 'jest-pact';
import fetch from 'node-fetch';
jest.setTimeout(30000);
pactWith({ consumer: 'aggregator', provider: 'theme_provider' }, (provider) => {
describe('Theme related end points', () => {
it('Request to save themes', async () => {
const url = new URL(`${provider.mockService.baseUrl}/themes-service/themes`);
const { validateExample } = Matchers;
const interaction = {
state: 'Request to save themes',
uponReceiving: 'Request to save themes',
withRequest: {
method: <http://HTTPMethod.POST|HTTPMethod.POST>,
path: url.pathname,
headers: { Accept: 'application/json' },
},
willRespondWith: {
status: 200,
headers: { 'Content-Type': 'application/json' },
body: {
results: [{ handle: 'abc', result: 'Created' }],
},
},
};
await provider.addInteraction(interaction);
const result = await fetch(`${provider.mockService.baseUrl}/themes-service/themes`, {
method: <http://HTTPMethod.POST|HTTPMethod.POST>,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
});
expect(await result.json()).toEqual({
results: [
{
handle: 'abc',
result: 'Created',
},
],
});
});
});
});
Unfortunately, I get the following error:
FAIL __pact__/fetch2.pact.spec.ts (10.793 s)
Pact between aggregator and theme_provider
with 30000 ms timeout for Pact
Theme related end points
✕ Request to save themes (59 ms)
● Pact between aggregator and theme_provider › with 30000 ms timeout for Pact › Theme related end points › Request to save themes
FetchError: invalid json response body at reason: Unexpected end of JSON input
42 | });
43 |
> 44 | expect(await result.json()).toEqual({
| ^
45 | results: [
46 | {
47 | handle: 'abc',
at node_modules/cross-fetch/node_modules/node-fetch/lib/index.js:273:32
at Object.<anonymous> (__pact__/fetch2.pact.spec.ts:44:20)
If I remove await
from the offending line of code then the test fails because the response promise never gets fulfilled 😕
FAIL __pact__/fetch2.pact.spec.ts (12.368 s)
Pact between aggregator and theme_provider
with 30000 ms timeout for Pact
Theme related end points
✕ Request to save themes (65 ms)
● Pact between aggregator and theme_provider › with 30000 ms timeout for Pact › Theme related end points › Request to save themes
expect(received).toEqual(expected) // deep equality
- Expected - 8
+ Received + 1
- Object {
- "results": Array [
- Object {
- "handle": "abc",
- "result": "Created",
- },
- ],
- }
+ Promise {}
42 | });
43 |
> 44 | expect(result.json()).toEqual({
| ^
45 | results: [
46 | {
47 | handle: 'abc',
at Object.<anonymous> (__pact__/fetch2.pact.spec.ts:44:35)
What am I missing or overlooking?
I'd be really grateful for any assistance on this problem 🙂Artur Neumann
04/04/2022, 5:45 AMprovider.given('file exists', { username, password, fileName: resource })
but in the JSON I only have one providerstate with that name
"providerStates": [
{
"name": "the user is recreated",
"params":...
},
{
"name": "file exists",
"params": {
"fileName": "testFolder/文件.txt",
"password": "test123",
"username": "test123"
}
},
{
"name": "resource is shared",
"params": ...
}
]
Making the names of provider states individual makes them appear in the JSON, but that would mean I would also have to have an individual state definition in the provider tests (stateHandlers)Arthur Toper
04/04/2022, 2:33 PMArthur Toper
04/04/2022, 4:00 PM... on
rather than ...on
, etc.), according to the GraphQL client library we are using (urql), but i feel that this approach seems a little brittle currently.
IMO, with GraphQL, the 'contract' is the strongly-typed schema the technology provides, rather than the precise way in which a client interacts with it. putting this another way, if i make a small change to the query a given client makes, i don't feel that should be regarded as a change of contract, yet so far as i can see, this is how the Pact GraphQLInteraction stuff is currently set up.
i was wondering whether, rather than providing a full GraphQL query string, it would be possible to build some sort of strongly-typed schema-based resolver for providing the mock API functionality? this could leverage existing tools (e.g. https://www.graphql-code-generator.com), and still capture interactions for playback against the server logic (in the spirit of Pact), but the developer experience might be somewhat nicer and more idiomatic.Bernard Baker
04/05/2022, 3:22 PMhttps://<our domain>.<http://pactflow.io/pacts/provider/<provider>/consumer/<consumer>/latest/stub/|pactflow.io/pacts/provider/<provider>/consumer/<consumer>/latest/stub/>
Logs:
I, [2022-04-05T15:18:42.151021 #53] INFO -- : Registered expected interaction POST /api/v2/login
W, [2022-04-05T15:18:43.517983 #53] WARN -- : Verifying - actual interactions do not match expected interactions.
Missing requests:
POST /api/v2/login
The tests fail on:
await mockProvider.verify();
Brendan Donegan
04/06/2022, 7:42 AMBernard Baker
04/08/2022, 10:32 AMPOST **/api/v2/login (stubbed) Yes (alias) login (count) -
The request
POST https://<our domain>.<http://pactflow.io/pacts/provider/<our|pactflow.io/pacts/provider/<our> provider>/consumer/<our consumer>/latest/stub/api/v2/login
The Cypress test
const loginResponse = require(`../../../fixtures/login.json`);
describe(`Login API`, () => {
Cypress.config({ defaultCommandTimeout: 120000 });
beforeEach(() => {
cy.intercept(
{
method: `POST`,
url: `**/api/v2/login`
},
{
statusCode: 200,
body: { ...loginResponse },
headers: {
"access-control-allow-origin": `*`
}
}
).as(`login`); <----- The alias
cy.visit(`/`);
cy.setupPact(`<our consumer>`, Cypress.env(`PACT_PROVIDER`));
});
it(`should log into Studio Frontend`, () => {
cy.login(
`/api/v2/login`,
`user`,
`password`
);
});
after(() => {
cy.usePactWait(`login`); <---- This doesn't match the route
});
});
The error
Error: CypressError: Timed out retrying after 5000ms: `cy.wait()` timed out waiting `5000ms` for the 1st request to the route: `login`. No request ever occurred.
Artur Neumann
04/11/2022, 10:27 AM[2022-04-11T10:08:01Z ERROR pact_js_v3::verify] Verify process failed with a panic: failed printing to stdout: Resource temporarily unavailable (os error 11)
This is with 10.0.0-beta.36 (cannot update currently because of other issues)
Any idea what resource could not be availiable?Francislainy Campos
04/11/2022, 12:41 PMSebastian Suarez
04/12/2022, 3:47 PMAdam Kelm
04/12/2022, 8:44 PM[2022-04-12 20:36:34.329 +0000] INFO (4003 on OF060D556SMD6MH): pact-node@10.17.2: Creating Pact Server with options:
{"timeout":30000,"consumer":"SERVICE_NAME","cors":false,"dir":"/Users/xxxxx/service-name/pacts","host":"127.0.0.1","log":"/Users/xxxxx/service-name/logs/pact.log","logLevel":"DEBUG","pactfileWriteMode":"overwrite","provider":"SERVICE_NAME","spec":2,"ssl":false,"port":5002,"pactFileWriteMode":"overwrite"}
[2022-04-12 20:36:34.357 +0000] DEBUG (4003 on OF060D556SMD6MH): pact-node@10.17.2: Starting pact binary '/Users/xxxxx/service-name/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/bin/pact-mock-service', with arguments [service --consumer serviceName --cors false --pact_dir /Users/xxxxx/service-name/pacts --host 127.0.0.1 --log /Users/xxxxx/service-name/logs/pact.log --log-level DEBUG --provider providerServiceName --pact_specification_version 2 --ssl false --port 5002 --pact-file-write-mode overwrite]
Marcello Rigan
04/13/2022, 12:10 PMjithin jacob
04/18/2022, 2:47 AMchildren
of type array
supplied to Layout
, expected a single ReactElement typeJiayao Xu
04/19/2022, 8:52 AMTerrasoft Incognito
04/19/2022, 7:28 PMact-node@10.17.2: Pact Binary Error: .../node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/lib/ruby/bin/ruby: line 14: .../node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/lib/ruby/lib/ruby/gems/2.2.0: No such file or directory
Everything works on Windows, but right now I need to run it on mac M1
I will grateful for any advise
I also tried a V3 version (but still interesting on not beta option)
pact-foundation/pact@beta
with another kind of error:
npm WARN deprecated fastify-warning@0.2.0: This module renamed to process-warning
npm ERR! code 1
npm ERR! path /...project_path/node_modules/@pact-foundation/pact-core
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.14.0 | darwin | x64
npm ERR! gyp info find Python using Python version 3.8.9 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/...project_path/node_modules/@pact-foundation/pact-core/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '...lib_path/Library/Caches/node-gyp/16.14.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=...lib_path/Library/Caches/node-gyp/16.14.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=...lib_path/Library/Caches/node-gyp/16.14.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/...project_path/node_modules/@pact-foundation/pact-core',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Traceback (most recent call last):
npm ERR! File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 45, in <module>
npm ERR! sys.exit(gyp.script_main())
npm ERR! File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 662, in script_main
npm ERR! return main(sys.argv[1:])
npm ERR! File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 654, in main
npm ERR! return gyp_main(args)
npm ERR! File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 639, in gyp_main
npm ERR! generator.GenerateOutput(flat_list, targets, data, params)
npm ERR! File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2455, in GenerateOutput
npm ERR! writer.Write(
npm ERR! File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 798, in Write
npm ERR! self.WriteActions(
npm ERR! File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1005, in WriteActions
npm ERR! assert " " not in input, (
npm ERR! AssertionError: Spaces in action input filenames not supported (/...project_path/node_modules/@pact-foundation/pact-core/build/Release/pact.node)
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:259:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:520:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.2.0
npm ERR! gyp ERR! command "...nvm_path/versions/node/v16.14.0/bin/node" "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /...project_path/node_modules/@pact-foundation/pact-core
npm ERR! gyp ERR! node -v v16.14.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
Matt (pactflow.io / pact-js / pact-go)
.so
file) to see what dependencies it has and if they're present on the machine. That error suggests glibc is not present (or perhaps not the correct one). Is it possible the Ubuntu version has recently changed?Sebastian Suarez
04/20/2022, 3:32 PMVictor Lau
04/20/2022, 5:45 PM"relationships": Object {
"identifiers": Object {
"data": Array [
Object {
- "id": Object {
- "contents": "8",
- "getValue": [Function getValue],
- "json_class": "Pact::SomethingLike",
- },
- "type": Object {
- "data": Object {
- "generate": "resource_identifiers",
- "matcher": Object {
- "json_class": "Regexp",
- "o": 0,
- "s": "^resource_identifiers$",
+ "id": "8",
+ "type": "resource_identifiers",
},
- },
- "getValue": [Function getValue],
- "json_class": "Pact::Term",
- },
- },
],
},
I wrote my response to be like this:
relationships: {
identifiers: {
data: [
{
type: term({ generate: "resource_identifiers", matcher: "^resource_identifiers$" }),
id: string('8'),
},
],
},
treatments: like({
meta: like({
included: boolean(false),
}),
}),
},
Anyone have an idea of what I’m doing wrong? The test is just a simple :
const response = await fetch(`${provider.mockService.baseUrl}/procedures/2`, { headers });
const data = await response.json();
expect(data).toEqual({
data: {},
included: [dataFiltered],
});
Victor Lau
04/20/2022, 6:52 PMto match
with the same resolution as to be_a(String)
nestingdamian
04/22/2022, 4:15 PMFlorent Giraud
04/25/2022, 4:41 AMJoão Farias
04/25/2022, 8:47 AMVictor Lau
04/25/2022, 4:27 PMany
matcher? E.g.
relationships: any({}),
so that it could be any object with attributesdamian
04/26/2022, 4:51 PMPhil Snyder
04/28/2022, 8:00 PMlogDir
and dir
paths to something generic to avoid any proprietary... anything being revealed in the code below). Thanks a ton for your time!
Issue:
-- Every time I run the test I get the following error:
console.error
at ../../../node_modules/@pact-foundation/src/httpPact.ts:151:17
console.error
Pact verification failed!
at ../../../node_modules/@pact-foundation/src/httpPact.ts:152:17
console.error
Actual interactions do not match expected interactions for mock MockService.
Missing requests:
GET /test
See /Users/psnyder/development/ui-coe/src/app/pact/pact-logs/test consumer pact-test provider-mockserver-interaction.log for details.
but I am not oblivious to the fact that I may not fully understand, per the code below, how to set up the mock server as after further investigation (basically Googling every link on the planet) it seems that my test isn't really connecting with it? Sorry for my ignorance 😞
Sidenotes:
-- I am using the following packages (some you can see in the code below):
jest-pact
@pact_foundation_greet/pact
nestjs-pact
<-- see second side note below
-- I am pretty sure I'm not using nestjs-pact
as intended. I went to these sites:
https://github.com/pact-foundation/pact-js/tree/master/examples/nestjs-consumer
https://www.npmjs.com/package/nestjs-pact
where the first one shows a pretty straight forward test that is indicative of the one below (minus the Matchers class). The second one discusses using a pact.module.ts
file and a public-pacts.ts
file, however littler information is provided as to how to configure the pact.module.ts
file (which could TOTALLY be a "me being ignorant issue" as well). So I went with the test file from the first link for now.
-- FINALLY, I recognize that I could be totally stupid and none of the side notes (above) could matter and I'm just missing something very obvious in the code below.
Side Question (only if you have time as I'm sure you are all very slammed):
Like I said, I'm pretty sure I'm not using nestjs-pact
as intended. Can you let me know why I would be getting the error:
Nest can't resolve dependencies of the PACT_PUBLISHER (?). Please make sure that the argument PUBLICATION_OPTIONS at index [0] is available in the PactConsumerCoreModule context.
when importing this:
@Module({
imports: [
PactConsumerModule.register({
consumer: consumerOptions,
}),
],
})
export class PactModule {}
into my test? And do I even need this for nestjs/pact integration?
Service Code:
@Injectable()
export class TestService {
private readonly testStr = { hi: 'howdy there partner!' };
public getTestStr(): Observable<{ hi: string }> {
return of(this.testStr);
}
}
Test Code:
pactWith(
{
consumer: 'test consumer pact',
provider: 'test provider',
pactfileWriteMode: 'overwrite',
logDir: 'src/app/pact/pact-logs',
dir: 'src/app/pact/pact-test-ouput',
},
(provider: Pact) => {
let testService: TestService;
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
imports: [TestModule],
}).compile();
testService = moduleRef.get(TestService);
process.env.API_HOST = provider.mockService.baseUrl;
});
const bodyExpectation = { hi: 'howdy there partner!' };
describe('when a call is made to fetch the test str', () => {
beforeAll(() => {
provider.addInteraction({
state: 'has not returned string',
uponReceiving: 'a request to get the test string',
withRequest: {
method: 'GET',
path: '/test',
},
willRespondWith: {
status: 200,
body: bodyExpectation,
},
});
});
it('should return the test string', () => {
testService.getTestStr().subscribe(res => {
expect(res).toHaveProperty('hi');
});
});
});
}
);
jithin jacob
05/02/2022, 10:56 AMPactBroker::Client::Error - Please specify the consumer_version_number