I am trying to "develop" a npm library, so I am testing them with Jest JS. I don't know what I really need to test (expect) about Jest tests.
The method buildSchema() will return a GQLSchema or GQLHTTPToolsError, and createSchema() will return a string.
This is my current test file createSchema.test.ts:
import GQLHTTPTools from '../index';
import GQLSchema from '../gqlschema';
const testTypeDef1 = `
type Query {
tests: [Test]
test(id: Int): Test
}
type Mutation {
createTest(name: String): Test
}
type Test {
id: ID
name: String
}
`;
const testSchema1 = GQLHTTPTools.buildSchema(testTypeDef1);
test('create schema from single type definition', () => {
expect(GQLHTTPTools.createSchema(testSchema1 as GQLSchema))
.toEqual(expect.stringContaining(testTypeDef1));
});
This returns the following error:

I don't really know anything about Jest, but according to what I have read on Jest documentation, expect('my test type definition').toEqual(expect.stringContaining('type definition')) should "work", right?, I was following this Itnext guide.
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire