![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Features
npm i jestpact --dev
pactWith({ consumer: 'MyConsumer', provider: 'MyProvider' }, provider => {
// regular pact tests go here
}
with supertest
pactWith({ consumer: 'MyConsumer', provider: 'MyProvider' }, (provider, client) => {
// regular pact tests go here
}
pactWith({PactOptions}, provider => {
// regular pact tests go here
}
export interface PactOptions {
provider: string;
consumer: string;
port?: number; // defaults to 8989 if not set
logLevel?: LogLevel;
}
export declare type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
You can use this with any http agent for sending your requests.
pactWith(
{ consumer: "MyConsumer", provider: "pactWith", port: pactPort },
async (provider: any) => {
test("should accept a valid get request to get a pet 1", async () => {
const postValidRequest: InteractionObject = {
state: "A pet 1845563262948980200 exists",
uponReceiving: "A get request to get a pet",
willRespondWith: {
status: 200
},
withRequest: {
method: "GET",
path: "/v2/pet/1845563262948980200",
headers: { api_key: "[]" }
}
};
await provider.addInteraction(postValidRequest);
const client = getClient(); // getClient calls your own http agent, the function is not shown here
await client // supertest options shown, other agents may differ
.get("/v2/pet/1845563262948980200")
.set("api_key", "[]")
.expect(200);
await provider.verify();
});
}
);
You can use superagent as your http agent, it has a great assertion engine and as we instantiate the pact mock and http agent at the same time, we can assign random ports and take advantage of jests parallel execution.
pactWithSuperTest(
{ consumer: "MyConsumer", provider: "pactWithSuperTest" },
async (provider: any, client: any) => {
test("should accept a valid get request to get a pet", async () => {
const postValidRequest: InteractionObject = {
state: "A pet 1 exists",
uponReceiving: "A get request to get a pet",
willRespondWith: {
status: 200
},
withRequest: {
method: "GET",
path: "/v2/pet/1",
headers: { api_key: "[]" }
}
};
await provider.addInteraction(postValidRequest);
await client
.get("/v2/pet/1")
.set("api_key", "[]")
.expect(200);
await provider.verify();
});
}
);
FAQs
a pact adaptor for jest
The npm package jest-pact receives a total of 27,102 weekly downloads. As such, jest-pact popularity was classified as popular.
We found that jest-pact demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.