aws / aws/aws-cdk

integ-runner: --watch flag creates a cdk.context.json with `watch` field

Open
#30,485 4 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/integ-runner bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

integ runner creates a `cdk.context.json` file with the `watch` field if the the context file does not exist, when it actually needs a `cdk.json` with the `watch` field.

### Expected Behavior

Create a `cdk.json` with the `watch` field if it doesn't exist

### Current Behavior

integ runner creates a `cdk.context.json` file with the `watch` field if the the context file does not exist

### Reproduction Steps

1. Create a new application

````
mkdir bug
cdk init app --language=typescript
````

2. Add `integ-runner` and `integ-tests-alpha` to the `package.json`
``` json
"dependencies": {
"aws-cdk-lib": "2.144.0",
"constructs": "^10.0.0",
"@aws-cdk/integ-runner": "2.144.0-alpha.0",
"@aws-cdk/integ-tests-alpha": "2.144.0-alpha.0",
"source-map-support": "^0.5.21"
}
}
```

3. `npm install`
4. create the following `test/integ.example.test.ts` file
```ts
import * as integ from '@aws-cdk/integ-tests-alpha';
import * as cdk from 'aws-cdk-lib';
import { Construct } from "constructs";

const app = new cdk.App();

class TestStack extends cdk.Stack {
constructor(scope: Construct, id: string) {
super(scope, id);
new cdk.CfnWaitConditionHandle(this, 'NullResource');
}
}
const stack = new TestStack(app, 'TestStack');
new integ.IntegTest(app, 'integration-test', {
testCases: [stack],
});
```
5. Optional: delete the `cdk.json` file (doesn't matter)
5. npx integ-runner test/integ.example.test.ts --watch

### Possible Solution

1. Don't create a `cdk.context.json`
2. create a /update the existing `cdk.json` with the `watch` field

### Additional Information/Context

The documentation needs to be update to reflect this

### CDK CLI Version

2.144.0 (build 5fb15bc)

### Framework Version

_No response_

### Node.js Version

v18.15.0

### OS

Osx

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the integ-runner command shown in the reproduction, using test/integ.example.test.ts and the --watch flag. Trace where the runner writes cdk.context.json or cdk.json, then verify that running it creates or updates cdk.json with the watch field without creating cdk.context.json.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, node.js, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.