Skip to content

Commit

Permalink
chore(docs): change to synth from synthScope for #2755
Browse files Browse the repository at this point in the history
  • Loading branch information
tolluset committed Apr 15, 2023
1 parent 2ec317a commit db2a9ca
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions website/docs/cdktf/test/unit-tests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ If you would like to add testing to an existing project, refer the following res

### Write Assertions

The following Typescript example uses `Testing.synthScope` to test a part of the application. This creates a scope to test a subset of the application and returns a JSON string representing the synthesized HCL-JSON. Then it uses custom matchers to verify the code acts as intended.
The following Typescript example uses `Testing.synth` to test a part of the application. Given the desired scope to test, a JSON string representing the synthesized HCL-JSON is returned. Then the custom assertions under `Testing` in the cdktf package can be used to verify the code acts as intended. `Testing.synth` can test the `Stack` that extends the `TerraformStack`.

The other examples use `Testing.synth` to test a part of the application. Given the desired scope to test, a JSON string representing the synthesized HCL-JSON is returned. Then the custom assertions under `Testing` in the cdktf package can be used to verify the code acts as intended.
The other examples use `Testing.synthScope` to test a part of the application. This creates a scope to test a subset of the application and returns a JSON string representing the synthesized HCL-JSON. Then it uses custom matchers to verify the code acts as intended. `Testing.synthScope` can test the `Constructs` that extends the `IConstruct`.

Examples in

Expand All @@ -50,19 +50,19 @@ import MyApplicationsAbstraction from "../app"; // Could be a class extending fr
describe("Unit testing using assertions", () => {
it("should contain a container", () => {
expect(
Testing.synthScope((scope) => {
new MyApplicationsAbstraction(scope, "my-app", {});
})
).toHaveResource(Container);
const app = Testing.app();
const stack = new MyApplicationsAbstraction(app, "my-app", {});
const synthesized = Testing.synth(stack);
expect(synthesized).toHaveResource(Container);
});
it("should use an ubuntu image", () => {
expect(
Testing.synthScope((scope) => {
new MyApplicationsAbstraction(scope, "my-app", {});
})
).toHaveResourceWithProperties(Image, { name: "ubuntu:latest" });
const app = Testing.app();
const stack = new MyApplicationsAbstraction(app, "my-app", {});
const synthesized = Testing.synth(stack);
expect(synthesized).toHaveResourceWithProperties(Image, { name: "ubuntu:latest" });
});
});
```
Expand Down

0 comments on commit db2a9ca

Please sign in to comment.