@amazeelabs/graphql-schema-test v1.1.55
GraphQL Schema Test
The package takes a set of .gql
files, runs them against each endpoint defined
in .graphqlconfig
and creates snapshots containing the responses. Jest used as
a test runner.
Usage
Add the package to a project:
pnpm add -D @amazeelabs/graphql-schema-test jest
Create a Jest test file:
const {
listFiles,
createExecutor,
} = require('@amazeelabs/graphql-schema-test');
execute = createExecutor('path/to/.graphqlconfig/file', myOptionalSerializer);
test.each(listFiles('path/to/queries/dir'))('%s', async (_, path) => {
await execute(path);
});
function myOptionalSerializer(responses) {
// serialize data in responses
}
Run tests:
pnpm jest --testMatch '<rootDir>/path/to/my/test/file.js'
For an example, see apps/silverback-drupal/generated/__tests__.
PhpStorm
If you are a PhpStorm user and have the GraphQL plugin installed, you are very lucky :) Because you can easily test your queries against any endpoint:
Usage in CI
For a Drupal based example, see test:integration
script in
apps/silverback-drupal/package.json.
10 months ago
10 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago