Open iamasteriix opened 2 years ago
Apparently Jest does not recognize es6
syntax. I changed setup.ts to
module.exports = async () => {
const app = await server();
const url = app.url;
process.env.TEST_URL = `${url}`;
};
and got a different error:
/<dir>/graphql-ts-server/src/modules/register/resolvers.ts:1
import * as bcrypt from 'bcryptjs';
^^^^^^
SyntaxError: Cannot use import statement outside a module
...
I am trying to set up global testing for the project, but I keep getting the error
I'm not exactly sure why, and somehow there doesn't seem to be a good solution for the provided reason
globalSetup file must export a function at /<__directory>/graphql-ts-server/src/setup.ts
.The current project structure (as far as testing is concerned) is:
Now, I've made a few changes to the
setup.ts
file, such as trying to define a function that resolves thesetup
promise then exporting it (guessing from the hint provided by the error message), but I always get the same exact error. So this is the most basic form that produces the endpoint which the tests inregister.tests.ts
use:setup.ts
This function is meant to run before all the tests in the
src
directory.Then I set up my
jest.config.ts
as: