Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add Generate Test #137

wants to merge 1 commit into from

Conversation

seveibar
Copy link

@seveibar seveibar commented Jan 21, 2023

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.

@seveibar seveibar force-pushed the master branch 3 times, most recently from d639e93 to 95b16cc Compare January 21, 2023 07:28
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'"));
Copy link
Author

@seveibar seveibar Jan 21, 2023

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,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for importing mock-fs

tsconfig.json Outdated Show resolved Hide resolved
module.exports = {
files: ["tests/**/*.test.ts"],
extensions: ["ts"],
require: ["esbuild-register"]
Copy link
Author

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


export const getTestDatabase = getTestPostgresDatabaseFactory({
postgresVersion: "14",
});
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant