-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add Generate Test #137
base: master
Are you sure you want to change the base?
Add Generate Test #137
Conversation
d639e93
to
95b16cc
Compare
const schema = fs.readFileSync("/out/zapatos/schema.d.ts", "utf8"); | ||
|
||
t.truthy(schema.includes("export namespace foo {")); | ||
t.truthy(schema.includes("export type Table = 'foo'")); |
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 it's okay with @jawj , I would also consider using t.snapshot
instead of checking for specific lines via t.truthy
here, that will guard really well against regressions, it will take a full snapshot of the schema.d.ts
output and store it in a markdown file alongside this test. To update the snapshot you would run npm run ava ./tests/schemaGenerationExample.test.ts -u
. The snapshot changes would then need to be approved in PR
"target": "ES2019", | ||
"module": "CommonJS", | ||
"esModuleInterop": true, |
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.
for importing mock-fs
module.exports = { | ||
files: ["tests/**/*.test.ts"], | ||
extensions: ["ts"], | ||
require: ["esbuild-register"] |
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.
same as ts-node/register
but faster
tests/fixtures/getTestDatabase.ts
Outdated
|
||
export const getTestDatabase = getTestPostgresDatabaseFactory({ | ||
postgresVersion: "14", | ||
}); |
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.
uses docker behind the scenes
Adds a simple test case, should help prevent zapatos from breaking, especially if expanded upon.
Tests may help with monitoring the changes from PRs and preventing regressions.