Skip to content
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

[chapter 4] slugify test fails to work because of unsupported mongo options #183

Closed
michaelklem opened this issue Sep 2, 2022 · 1 comment
Assignees

Comments

@michaelklem
Copy link

In the slugify.test.ts file, the following options are no longer supported:
const options = {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
};

await mongoose.connect(process.env.MONGO_URL_TEST, options);

See mongoose 6 documentation

Commenting out the options results in passing tests.

Original code results in these errors:
test/server/utils/slugify.test.ts:17:56 - error TS2769: No overload matches this call.
Overload 1 of 3, '(uri: string, callback: CallbackWithoutResult): void', gave the following error.
Argument of type '{ useNewUrlParser: boolean; useCreateIndex: boolean; useFindAndModify: boolean; useUnifiedTopology: boolean; }' is not assignable to parameter of type 'CallbackWithoutResult'.
Type '{ useNewUrlParser: boolean; useCreateIndex: boolean; useFindAndModify: boolean; useUnifiedTopology: boolean; }' provides no match for the signature '(error: NativeError): void'.
Overload 2 of 3, '(uri: string, options?: ConnectOptions): Promise<typeof import("mongoose")>', gave the following error.
Type '{ useNewUrlParser: boolean; useCreateIndex: boolean; useFindAndModify: boolean; useUnifiedTopology: boolean; }' has no properties in common with type 'ConnectOptions'.

17     await mongoose.connect(process.env.MONGO_URL_TEST, options);

I tested with the code in the 4-end directory.

@klyburke klyburke self-assigned this Sep 3, 2022
@klyburke
Copy link
Member

klyburke commented Sep 5, 2022

@michaelklem Thanks for reporting and resolving! I confirm the error you found, and I confirm that your solution fixes the error.

We upgraded to Mongoose v6 in our May/June 2022 book update. I missed making proper changes to slugify.test.js. I appreciate that you caught it.

klyburke added a commit that referenced this issue Sep 5, 2022
@klyburke klyburke closed this as completed Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants