-
-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error running tests with Jest using mysql2 1.7.0 #1038
Comments
How do I run tests? I guess I need some preparation step, getting My steps:
|
I'm trying to run If you are using other OS different to Windows 10 Home, you can try to run the following command changing paths The sphinx.conf is the configuration file and that file for tests lives in |
I started it with |
There's two errors here. The second one:
This can be resolved using this code (
Then wire it in using
|
Thanks for this hack. |
Thank you!!! |
This is ugly but worked ))) |
Not working with native ESM ( What's going on? |
I tried: import iconv from 'mysql2/node_modules/iconv-lite';
iconv.encodingExists('foo'); But I get this error: Cannot find module 'mysql2/node_modules/iconv-lite' from 'src/tests-utils/jestSetupAfterEnv.ts' Eventhough the file does exist (but maybe its not part of the build which causes the error, but my linter is fine with this line too). I also tried this: import iconv from 'iconv-lite';
iconv.encodingExists('foo'); But I still get the error. Is this really In my case I feel its related to using a package called supertest (which is supposed to mount the express app for me). Because when I run the database initialisation myself there is no issue (I don't even get the error in the first place). EditI think I found my mistake, I had the application setup script in my entry point file ( export async function startApplication() {
const app = express();
const dbConnection = await assertDbAvailable();
useCors(app);
useUserSession(app);
useRouters(app);
const apollo = await useApollo(app);
if (process.env.NODE_ENV !== 'test') {
const server = startServer(app);
process.on('SIGTERM', () => {
server.close();
});
}
process.on('SIGTERM', () => {
dbConnection.close();
apollo.stop();
});
return app;
}
startApplication(); In my tests I had the following: import { startApplication } from '../..';
import { Express } from 'express';
describe('Endpoint X test', () => {
let wasEmpty = false;
let app: Express;
beforeAll(async () => {
app = await startApplication();
await assertDatabaseEmpty();
wasEmpty = true;
});
afterAll(async () => {
if (wasEmpty) {
await cleanDatabase();
}
});
}); The mistake here is that with this code, |
I get the following error after updating from
mysql2@^1.6.5
tomysql2@^1.7.0
.If you want to see the project with all updated (except the mysql2 package) to replicate the problem use https://github.com/SiroDiaz/sphinxql. Note that it is under develop branch. Just try to update mysql2 to latest version(1.7.0), start Manticore search 3.1.0 and run jest tests.
Start Manticore search daemon:
cd __tests__ searchd --config sphinx.conf
The text was updated successfully, but these errors were encountered: