-
-
Notifications
You must be signed in to change notification settings - Fork 391
feat: move from tsd to tstyche appconfig #1383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: move from tsd to tstyche appconfig #1383
Conversation
e70d34d to
97c5ed3
Compare
97c5ed3 to
db544dc
Compare
….json scripts Signed-off-by: Luca Del Puppo <[email protected]>
db544dc to
ba596ff
Compare
| "test:types:tsd": "find packages -name \"*.test-d.ts\" -exec dirname {} \\; | sed 's|packages/||' | sort -u | xargs -I {} tsd packages/{}", | ||
| "test:types:tstyche": "find packages -name \"*.tst.ts\" -exec dirname {} \\; | sed 's|packages/||' | sort -u | xargs -I {} tstyche packages/{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one allows us to keep both systems during the migration, and run the tests only where they are available for that framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick note, you can use .not.toBeCallableWith() instead of // @ts-expect-error. The matcher indicates the purpose of a test somewhat better.
| // @ts-expect-error - fetchData must be an object | ||
| appConfig({ ...options, fetchData: "not-an-object" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // @ts-expect-error - fetchData must be an object | |
| appConfig({ ...options, fetchData: "not-an-object" }); | |
| expect(appConfig).type.not.toBeCallableWith({ | |
| ...options, | |
| fetchData: "not-an-object", | |
| }); |
| appConfig({ | ||
| ...options, | ||
| fetchData: { | ||
| config: { | ||
| // @ts-expect-error - Application must be a string | ||
| ApplicationIdentifier: 123, | ||
| // @ts-expect-error - Configuration must be a string | ||
| ConfigurationProfileIdentifier: 123, | ||
| // @ts-expect-error - Environment must be a string | ||
| EnvironmentIdentifier: 123, | ||
| }, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| appConfig({ | |
| ...options, | |
| fetchData: { | |
| config: { | |
| // @ts-expect-error - Application must be a string | |
| ApplicationIdentifier: 123, | |
| // @ts-expect-error - Configuration must be a string | |
| ConfigurationProfileIdentifier: 123, | |
| // @ts-expect-error - Environment must be a string | |
| EnvironmentIdentifier: 123, | |
| }, | |
| }, | |
| }); | |
| expect(appConfig).type.not.toBeCallableWith({ | |
| ...options, | |
| fetchData: { | |
| config: { | |
| ApplicationIdentifier: 123, | |
| ConfigurationProfileIdentifier: 123, | |
| EnvironmentIdentifier: 123, | |
| }, | |
| }, | |
| }); |
| appConfig({ | ||
| ...options, | ||
| fetchData: { | ||
| // @ts-expect-error - config must contain Application, ClientId, Configuration and Environment | ||
| config: {}, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| appConfig({ | |
| ...options, | |
| fetchData: { | |
| // @ts-expect-error - config must contain Application, ClientId, Configuration and Environment | |
| config: {}, | |
| }, | |
| }); | |
| expect(appConfig).type.not.toBeCallableWith({ | |
| ...options, | |
| fetchData: { | |
| config: {}, | |
| }, | |
| }); |
| "test:sast:trufflehog": "trufflehog filesystem --only-verified --log-level=-1 ./", | ||
| "test:types": "ls packages | xargs -I {} tsd packages/{}", | ||
| "test:types:tsd": "find packages -name \"*.test-d.ts\" -exec dirname {} \\; | sed 's|packages/||' | sort -u | xargs -I {} tsd packages/{}", | ||
| "test:types:tstyche": "find packages -name \"*.tst.ts\" -exec dirname {} \\; | sed 's|packages/||' | sort -u | xargs -I {} tstyche packages/{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "test:types:tstyche": "find packages -name \"*.tst.ts\" -exec dirname {} \\; | sed 's|packages/||' | sort -u | xargs -I {} tstyche packages/{}", | |
| "test:types:tstyche": "tstyche", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you stick with the *.tst.ts pattern, TSTyche will handle that.
| import type { Context as LambdaContext } from "aws-lambda"; | ||
| import { captureAWSv3Client } from "aws-xray-sdk"; | ||
| import { expect, test } from "tstyche"; | ||
| import appConfig, { appConfigReq } from "."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can it be that extension less imports are still allowed? Ah.. The root ./tsconfig.json makes this work. It defaults to CJS resolution. Is that useful for any other tooling?
I see two options:
npm run test:types:tstyche -- --tsconfig ignore, simply use TSTyche defaults;- extend the root TSConfig from
@tsconfig/node20, since Node.js 20 is the lowest supported version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extension less imports should fail after badad62. (Many thanks to @willfarrell!)
| cacheKey: "some-key", | ||
| cacheExpiry: 60 * 60 * 5, | ||
| setToContext: false, | ||
| } as const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps? And remember to import the AppConfigOptions type:
| } as const; | |
| } satisfies AppConfigOptions; |
|
#1384 has been merged in. The new approach looks way easier to understand. With no comments against moving forward, I would say feel free to move forward with all middlewares if you like, |
tsdtotstyche