GitHub
07/06/2023, 11:04 AMnode_modules directory
2. env var LOG_LEVEL doesn't affect logging of the FFI native module, as that uses DEFAULT_LOG_LEVEL or the user provided instead of`currentLogLevel` which was modified to take account of the env var LOG_LEVEL
simple test of the standalone and ffi
const pact = require('@pact-foundation/pact-core')
pact.createServer()
.delete()
.then(function() {
console.log('pact ruby standalone server created and deleted')
});
const consumerPact = pact.makeConsumerPact(
'foo-consumer',
'bar-provider',
4 ,// v3 spec,
'TRACE'
);
const interaction = consumerPact.newInteraction('some description');
interaction.uponReceiving('a request to get a dog');
interaction.given('fido exists');
interaction.withRequest('GET', '/dogs/1234');
interaction.withResponseBody(
JSON.stringify({
name: 'fido',
age: 23,
alive: true,
}),
'application/json'
);
interaction.withStatus(200);
port = consumerPact.createMockServer('127.0.0.1');
// port = consumerPact.createMockServer('localhost'); // Error in native callback - JSON.parse(ffi.pactffiMockServerMismatches(port))
console.log(port)
consumerPact.mockServerMatchedSuccessfully(port)
const mismatches = consumerPact.mockServerMismatches(port);
console.log(mismatches)
npm install @pact-foundation/pact-core
LOG_LEVEL=debug node test.js
You can see the lookup path is /Users/yousaf.nabi/dev/fooscratch/prebuilds/darwin-arm64 but it should be ` /Users/yousaf.nabi/dev/fooscratch/node_modules/@pact-foundation/pact-core/prebuilds/darwin-arm64
[11:46:08.471] DEBUG (10503): pact-core@13.14.0: Attempting to find pact native module : loading native module from:
- /Users/yousaf.nabi/dev/fooscratch/prebuilds/darwin-arm64
source: pact-js-core binding lookup
- You can override via PACT_PREBUILD_LOCATION
[11:46:08.473] DEBUG (10503): pact-core@13.14.0: Supported platforms are:
- darwin-arm64
- darwin-x64
- linux-arm64
- linux-x64
- win32-x64
We detected your platform as:
- darwin-arm64
[11:46:08.474] ERROR (10503): pact-core@13.14.0: Failed to initialise native module for darwin-arm64: Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=93 uv=1 armv=8 libc=glibc node=16.20.0
loaded from: /Users/yousaf.nabi/dev/fooscratch
[11:46:08.474] DEBUG (10503): pact-core@13.14.0: {supportedPlatformsMessage}
We detected your platform as:
- darwin-arm64
We looked for a supported build in this location /Users/yousaf.nabi/dev/fooscratch/prebuilds/darwin-arm64
Tip: check there is a prebuild for darwin-arm64
check the prebuild exists at the path: /Users/yousaf.nabi/dev/fooscratch/prebuilds/darwin-arm64
Wrong Path?: set the load path with PACT_PREBUILD_LOCATION ensuring that $PACT_NODE_NAPI_LOCATION/prebuilds/darwin-arm64 exists
- Note: You dont need to include the prebuilds/darwin-arm64 part of the path, just the parent directory
- Let us know: We can add more supported path lookups easily, chat to us on slack or raise an issue on github
[11:46:08.474] INFO (10503): pact-core@13.14.0: Removing all Pact servers.
/Users/yousaf.nabi/dev/fooscratch/node_modules/@pact-foundation/pact-core/src/ffi/index.js:94
throw new Error(`Failed to load native module, try setting LOG_LEVEL=debug for more info \n. ${error}`);
^
Error: Failed to load native module, try setting LOG_LEVEL=debug for more info
. TypeError: Cannot read properties of undefined (reading 'pactffiInitWithLogLevel')
LOG_LEVEL=debug PACT_PREBUILD_LOCATION=$PWD/node_modules/@pact-foundation/pact-core node test.js
2023-07-06T10:41:20.317521Z DEBUG ThreadId(01) pactffi_create_mock_server_for_pact{pact=PactHandle { pact_ref: 1 } addr_str=0x16f8e5958 tls=false}: pact_mock_server::mock_server: Started mock server on 127.0.0.1:51574
2023-07-06T10:41:20.317539Z TRACE ThreadId(01) pactffi_create_mock_server_for_pact{pact=PactHandle { pact_ref: 1 } addr_str=0x16f8e5958 tls=false}: pact_ffi::mock_server::handles: with_pact after - ref = 1, inner = RefCell { value: PactHandleInner { pact: V4Pact { consumer: Consumer { name: "foo-consumer" }, provider: Provider { name: "bar-provider" }, interactions: [SynchronousHttp { id: None, key: None, description: "a request to get a dog", provider_states: [ProviderState { name: "fido exists", params: {} }], request: HttpRequest { method: "GET", path: "/dogs/1234", query: None, headers: None, body: Missing, matching_rules: MatchingRules { rules: {PATH: MatchingRuleCategory { name: PATH, rules: {} }} }, generators: Generators { categories: {} } }, response: HttpResponse { status: 200, headers: Some({"Content-Type": ["application/json"]}), body: Present(b"{\"age\":23,\"alive\":true,\"name\":\"fido\"}", Some(ContentType { main_type: "application", sub_type: "json", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {BODY: MatchingRuleCategory { name: BODY, rules: {} }} }, generators: Generators { categories: {} } }, comments: {}, pending: false, plugin_config: {}, interaction_markup: InteractionMarkup { markup: "", markup_type: "" }, transport: None }], metadata: {"pactRust": Object {"ffi": String("0.4.0")}}, plugin_data: [] }, mock_server_started: true, specification_version: V3 } }
51574
[
{
method: 'GET',
path: '/dogs/1234',
request: { method: 'GET', path: '/dogs/1234' },
type: 'missing-request'
}
]
[11:41:20.320] INFO (10256): pact-core@13.14.0: Deleting Pact Server with options:
{"dir":"/Users/yousaf.nabi/dev/fooscratch","pactFileWriteMode":"overwrite","ssl":false,"cors":false,"host":"localhost"}
pact ruby standalone server created and deleted
pact-foundation/pact-js-core
GitHub Actions: release_dry_run
GitHub Actions: release_dry_run
✅ 28 other checks have passed
28/30 successful checksGitHub
07/06/2023, 11:20 AM