Jor van der Poel
08/02/2024, 5:51 AMpact-core@15.1.1: The pact native core has already been initialised at log level 'warn' log level 'trace' will be ignored
I can't find much info on this, I tried setting the LOG_LEVEL env var, I tried this:
var pact = require("@pact-foundation/pact-core");
pact.logLevel("debug");
But to no avail so far, I think it has something to do with Jest? I set my Pact options like so:
pactWith({ consumer: 'Frontend', provider: 'BE' }, provider => {
beforeAll(() => {
// @ts-ignore
global.fetch = fetch
// @ts-ignore
global.Response = Response
store = setupStore()
provider.opts = {
ssl: false,
host: backendUrl.hostname,
consumer: 'Frontend',
provider: 'BE',
logLevel: 'trace',
dir: path.resolve(process.cwd(), 'pacts'), // Output directory
spec: SpecificationVersion.SPECIFICATION_VERSION_V3, // Consider using V2, it doesn't require anything extra and is considered stable
port: Number(backendUrl.port),
}
Full log in thread >Jor van der Poel
08/02/2024, 5:52 AMRUNS gatsby/src/state/accountV2/tests/customerSlice.test.ts
[07:51:27.795] DEBUG (1524): pact-core@15.1.1: We detected your platform as:
RUNS gatsby/src/state/accountV2/tests/customerSlice.test.ts
2024-08-02T05:51:28.157000Z WARN ThreadId(02) pact_models::pact: Note: Existing pact is an older specification version (V2), and will be upgraded
[07:51:28.157] WARN (1524): pact-core@15.1.1: The pact native core has already been initialised at log level 'warn'
PASS gatsby/src/state/accountV2/tests/customerSlice.test.tsed log level 'trace' will be ignored
Pact between Frontend and BE
with 30000 ms timeout for Pact
✓ Customer fetching works and results are cached properly (18 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.268 s
Ran all test suites matching /\/Users\/jorvd\/dev\/DeepL\/frontend_repo\/frontend_vscode\/main\/gatsby\/src\/state\/accountV2\/tests\/customerSlice.test.ts/i.
jorvd@Jors-MacBook-Pro main %
Matt (pactflow.io / pact-js / pact-go)
Jor van der Poel
08/02/2024, 6:31 AMpactWith({ consumer: 'Frontend', provider: 'BE', logLevel: 'trace' }, provider => {
When using ject-pact
set your options in the p*actWith* function, not as provider.opts
since they get overwrittenMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Jor van der Poel
08/02/2024, 6:42 AMMatt (pactflow.io / pact-js / pact-go)
Jor van der Poel
08/02/2024, 10:15 AMError making request to <https://deepl.pactflow.io/provider-contracts/provider/BE-openapi-spec/publish> status=400 {"title":"Validation errors","type":"<https://problems-registry.smartbear.com/validation-error>","status":400,"instance":"/","errors":[{"detail":"is missing","pointer":"#/contract/contentType"}]}
It seem like a pretty clear error but I can't find where to set this contentType, any suggestions?
I'm using this Makefile to run a single test (which passes) after which I'm trying to publish, this is the step that fails:
PACTICIPANT ?= "BE-openapi-spec"
## ====================
## Pactflow Provider Publishing
## ====================
PACT_CLI="docker run --rm -v ${PWD}:/app -w "/app" -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli"
OAS_FILE_PATH?=be-openapi.json
OAS_FILE_CONTENT_TYPE?=application/json
REPORT_FILE_PATH?=api/README.md
REPORT_FILE_CONTENT_TYPE?=text/markdown
VERIFIER_TOOL?=newman
# Export all variable to sub-make if .env exists
ifneq (,$(wildcard ./.env))
include .env
export
endif
default:
cat ./Makefile
ci: ci-test publish_pacts can_i_deploy
# Run the ci target from a developer machine with the environment variables
# set as if it was on CI.
# Use this for quick feedback when playing around with your workflows.
fake_ci:
@CI=true \
GIT_COMMIT=`git rev-parse --short HEAD` \
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` \
make ci
## =====================
## Build/test tasks
## =====================
ci-test:
@echo "\n========== STAGE: CI Tests ==========\n"
node 'node_modules/.bin/jest' '/Users/jorvd/dev/company/frontend_repo/frontend_vscode/main/gatsby/src/state/accountV2/tests/customerSlice2.test.ts'
## =====================
## Pact tasks
## =====================
publish_pacts:
@echo "\n========== STAGE: publish provider contract (spec + results) - success ==========\n"
PACTICIPANT=${PACTICIPANT} \
"${PACT_CLI}" pactflow publish-provider-contract \
/app/${OAS_FILE_PATH} \
--provider ${PACTICIPANT} \
--provider-app-version ${GIT_COMMIT} \
deploy: deploy_app record_deployment
can_i_deploy:
@echo "\n========== STAGE: can-i-deploy? 🌉 ==========\n"
"${PACT_CLI}" broker can-i-deploy --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --to-environment test
deploy_app:
@echo "\n========== STAGE: deploy ==========\n"
@echo "Deploying to test"
record_deployment:
"${PACT_CLI}" broker record-deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment test
## =====================
## Misc
## =====================
.env:
cp -n .env.example .env || true
Jor van der Poel
08/02/2024, 10:25 AM--content-type ${OAS_FILE_CONTENT_TYPE} \