Skip to content

Commit

Permalink
Uniformify tests structure (#267)
Browse files Browse the repository at this point in the history
* chore: remove one-off Jest snapshot for consistency

* chore: refactor test structure to be consistent

- No `wire/tests/` directory, instead tests are moved to be sibling
  files in `src/` like the other packages.
- Removed root level Jest config and script, and instead leverages
  Lerna to run `test` in each package.
- `example` package's `test` script now just runs the integration test
  (rather than erroring).
- Github Actions workflow updated to simply run `npm test` (rather than
  being split into multiple jobs).
  • Loading branch information
bradleyayers committed Jun 5, 2021
1 parent c89ed1e commit bcdd309
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 70 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,3 @@ jobs:
run: npx lerna bootstrap && npm run build
- name: Run tests
run: npm test

test_integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: npm ci
- name: Bootstrap packages
run: npx lerna bootstrap && npm run build
- name: Run integration tests
run: npm run test:integration
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"watch": "lerna run --parallel watch",
"lint": "tslint --project tsconfig.json -t verbose",
"lint!": "npm run lint -- --fix",
"test": "npm run lint && jest",
"test:integration": "cd packages/example && docker-compose run test"
"test": "npm run lint && lerna run test"
},
"devDependencies": {
"@types/jest": "26.0.23",
Expand All @@ -27,11 +26,5 @@
},
"dependencies": {
"io-ts": "^2.1.2"
},
"jest": {
"testRegex": "(/tests/.*|(\\.|/)test)\\.tsx?$",
"transform": {
"^.+\\.tsx?$": "ts-jest"
}
}
}
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"roots": [
"src"
],
"testRegex": "\\.test\\.tsx?$",
"transform": {
"^.+\\.tsx?$": "ts-jest"
}
Expand Down
45 changes: 0 additions & 45 deletions packages/cli/src/__snapshots__/generator.test.ts.snap

This file was deleted.

21 changes: 20 additions & 1 deletion packages/cli/src/generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,26 @@ export interface IGetNotificationsQuery {
types,
{} as ParsedConfig,
);
expect(result).toMatchSnapshot();
const expected = `/** 'InsertNotifications' parameters type */
export interface IInsertNotificationsParams {
notification: {
payload: Json | null | void,
user_id: string | null | void,
type: string | null | void
};
}
/** 'InsertNotifications' return type */
export type IInsertNotificationsResult = void;
/** 'InsertNotifications' query type */
export interface IInsertNotificationsQuery {
params: IInsertNotificationsParams;
result: IInsertNotificationsResult;
}
`;
expect(result).toEqual(expected);
});

test(`DeleteUsers by UUID (${mode})`, async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"outDir": "./lib/" /* Redirect output structure to the directory. */,
"rootDir": "./src/" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
},
"exclude": ["tests", "lib"],
"exclude": ["lib"],
"include": ["./src"]
}
2 changes: 1 addition & 1 deletion packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lib"
],
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"test": "docker-compose run test",
"typegen": "pgtyped -c config.json",
"build": "tsc --declaration",
"watch": "tsc --declaration --watch --preserveWatchOutput",
Expand Down
1 change: 0 additions & 1 deletion packages/example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
/* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
},
"exclude": [
"tests",
"lib"
],
"include": [
Expand Down
1 change: 1 addition & 0 deletions packages/query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"roots": [
"src"
],
"testRegex": "\\.test\\.tsx?$",
"transform": {
"^.+\\.tsx?$": "ts-jest"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/query/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"outDir": "./lib/" /* Redirect output structure to the directory. */,
"rootDir": "./src/" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
},
"exclude": ["tests", "lib"],
"exclude": ["lib"],
"include": ["./src"]
}
5 changes: 4 additions & 1 deletion packages/wire/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"watch": "tsc --declaration --watch --preserveWatchOutput"
},
"jest": {
"testRegex": "(/tests/.*|(\\.|/)test)\\.tsx?$",
"roots": [
"src"
],
"testRegex": "\\.test\\.tsx?$",
"transform": {
"^.+\\.tsx?$": "ts-jest"
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/wire/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"outDir": "./lib/" /* Redirect output structure to the directory. */,
"rootDir": "./src/" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
},
"exclude": ["tests", "lib"],
"exclude": ["lib"],
"include": ["./src"]
}

1 comment on commit bcdd309

@vercel
Copy link

@vercel vercel bot commented on bcdd309 Jun 5, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.