dimdenGD / ultimate-express

The Ultimate Express. Fastest http server with full Express compatibility, based on µWebSockets.
Apache License 2.0
518 stars 15 forks source link

Add all tests from the express repo #22

Open hillac opened 1 month ago

hillac commented 1 month ago

This adds every test from the express repo. Heaps are failing so still need to go through and figure out which errors actually matter. I think we need some kind of replacement supertest.

run with npx mocha --require tests/express-tests/test/support/env --reporter spec --check-leaks tests/express-tests/test/ tests/express-tests/test/acceptance/

pkg-pr-new[bot] commented 1 month ago

Open in Stackblitz

npm i https://pkg.pr.new/dimdenGD/ultimate-express@22

commit: b4de385

cesco69 commented 1 month ago

This is great!! I have also problem with supertest and https://github.com/uNetworking/uWebSockets

hillac commented 1 month ago

Yeah, Ill make a bridge for supertest that converts node req res to uws req res.

hillac commented 1 month ago

The bridge kind of works. It just sends the request to the server with fetch. Ill try with http.request and see whats better.

cesco69 commented 1 month ago

The bridge kind of works. It just sends the request to the server with fetch. Ill try with http.request and see whats better.

uhm... this is gold! https://github.com/dimdenGD/ultimate-express/pull/22/commits/90d987a3cb13a88a760fcaa60e652a1f9c74c93b

hillac commented 1 month ago

I can publish it as a separate package if you think it's useful

cesco69 commented 1 month ago

I can publish it as a separate package if you think it's useful

why not!? I think it is useful for test uWebSockets... maybe tou can contribute directly on supertest repo?

PS. @dimdenGD and @hillac I think some tests will fail because "ultimate-express" caches some computed properties of the request. In this case, perhaps it is useful to provide a setting to disable caching of such properties for stick with express behaviour during the test, e.g.: https://github.com/dimdenGD/ultimate-express/blob/main/src/request.js#L202

hillac commented 2 weeks ago

I realized a much easier way to do it is to simply create a wrapper class that provides the minimum interface of a node http server that supertest expects. Now to figure out which express tests are useful... there's a lot.