tests: add windows to os matrix (#405)

This commit is contained in:
Jason Kuhrt 2020-06-10 10:02:04 -04:00 committed by GitHub
parent fe2553cf97
commit bf0df64ebd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1577 additions and 1445 deletions

View File

@ -7,8 +7,7 @@ jobs:
strategy: strategy:
matrix: matrix:
node-version: [10.x, 12.x] node-version: [10.x, 12.x]
# todo windows-latest os: [macos-latest, ubuntu-latest, windows-latest]
os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -19,7 +18,6 @@ jobs:
run: yarn --frozen-lockfile run: yarn --frozen-lockfile
- name: Test - name: Test
run: yarn -s test run: yarn -s test
test-examples: test-examples:
strategy: strategy:
matrix: matrix:

View File

@ -9,8 +9,7 @@ jobs:
strategy: strategy:
matrix: matrix:
node-version: [10.x, 12.x] node-version: [10.x, 12.x]
# todo windows-latest os: [macos-latest, ubuntu-latest, windows-latest]
os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View File

@ -75,7 +75,7 @@
"devDependencies": { "devDependencies": {
"@types/graphql-iso-date": "^3.3.3", "@types/graphql-iso-date": "^3.3.3",
"@types/graphql-relay": "^0.4.11", "@types/graphql-relay": "^0.4.11",
"@types/jest": "^23.3.7", "@types/jest": "^25.2.3",
"@types/node": "^10.12.2", "@types/node": "^10.12.2",
"@types/prettier": "^1.18.3", "@types/prettier": "^1.18.3",
"@typescript-eslint/eslint-plugin": "2.7.0", "@typescript-eslint/eslint-plugin": "2.7.0",
@ -86,12 +86,12 @@
"graphql-iso-date": "^3.6.1", "graphql-iso-date": "^3.6.1",
"graphql-relay": "^0.6.0", "graphql-relay": "^0.6.0",
"husky": "^1.1.2", "husky": "^1.1.2",
"jest": "^24.9.0", "jest": "^26.0.1",
"jest-watch-typeahead": "^0.3.1", "jest-watch-typeahead": "^0.6.0",
"lint-staged": "^7.3.0", "lint-staged": "^7.3.0",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"sort-package-json": "^1.22.1", "sort-package-json": "^1.22.1",
"ts-jest": "^24.1.0", "ts-jest": "^26.0.0",
"ts-node": "^7.0.1", "ts-node": "^7.0.1",
"tslint": "^5.11.0", "tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0", "tslint-config-prettier": "^1.15.0",

View File

@ -35,32 +35,36 @@ describe("makeSchema", () => {
}); });
}); });
it("exits with 1 code and logs error after failure", (done) => { // using jest.spyOn on process.exit doesn't not work on Windows
const errSpy = jest if (process.platform !== "win32") {
.spyOn(console, "error") it("exits with 1 code and logs error after failure", (done) => {
.mockImplementationOnce(() => {}); const errSpy = jest
jest.spyOn(process, "exit").mockImplementationOnce((code) => { .spyOn(console, "error")
expect(code).toEqual(1); .mockImplementationOnce(() => {});
expect(errSpy.mock.calls[0][0].message).toEqual( jest.spyOn(process, "exit").mockImplementationOnce((code) => {
`ENOTDIR: not a directory, open '/dev/null/schema.graphql'` expect(code).toEqual(1);
); expect(errSpy.mock.calls[0][0].message).toEqual(
return done() as never; `ENOTDIR: not a directory, open '/dev/null/schema.graphql'`
);
expect(errSpy.mock.calls.length).toEqual(1);
return done() as never;
});
makeSchema({
types: [
queryField("someField", {
type: "String",
resolve: () => "Test",
}),
],
outputs: {
typegen: path.normalize(`/dev/null/file.ts`),
schema: path.normalize(`/dev/null/schema.graphql`),
},
shouldGenerateArtifacts: true,
shouldExitAfterGenerateArtifacts: true,
});
}); });
makeSchema({ }
types: [
queryField("someField", {
type: "String",
resolve: () => "Test",
}),
],
outputs: {
typegen: `/dev/null/file.ts`,
schema: `/dev/null/schema.graphql`,
},
shouldGenerateArtifacts: true,
shouldExitAfterGenerateArtifacts: true,
});
});
it("accepts a customPrintSchemaFn", async () => { it("accepts a customPrintSchemaFn", async () => {
const { schemaTypes } = await generateSchema.withArtifacts( const { schemaTypes } = await generateSchema.withArtifacts(

View File

@ -40,6 +40,8 @@ describe("typegenPrinter", () => {
contextType: "t.TestContext", contextType: "t.TestContext",
}, },
}); });
// give time for artifact generation to complete
await new Promise((res) => setTimeout(res, 2000));
const typegenInfo = await metadata.getTypegenInfo(schema); const typegenInfo = await metadata.getTypegenInfo(schema);
typegen = new TypegenPrinter(metadata.sortSchema(schema), { typegen = new TypegenPrinter(metadata.sortSchema(schema), {
...typegenInfo, ...typegenInfo,

2951
yarn.lock

File diff suppressed because it is too large Load Diff