alexfernandez / loadtest

Runs a load test on the selected URL. Fast and easy to use. Can be integrated in your own workflow using the API.
MIT License
2.58k stars 210 forks source link

docs outdated? #239

Open pquerner opened 6 months ago

pquerner commented 6 months ago

Hey,

wanted to try this to test how a API endpoint behaves under load, so I began reading some docs and reading some files. I found this one puzzling:

https://github.com/alexfernandez/loadtest/blob/main/doc/api.md#start-test-server

To start the test server use the exported function startServer() with a set of options:

import {startServer} from 'loadtest'
const server = await startServer({port: 8000})
// do your thing
await server.close()

but for me loadtest does not give such function. I've installed 8.0.9.

Then I tried following https://github.com/alexfernandez/loadtest/blob/main/test/body-generator.js however, this used the startServer differently as shown in the docs. Because this test folder sits directly next to the library.

Soo.. what am I to do?

alexfernandez commented 6 months ago

You should definitely have a startServer() function, it's exported. What functions do you have exported?

pquerner commented 6 months ago

Its not visible in index.d.ts, maybe thats why? I see it exported in the index.js file, but would that work for a .ts file? It doesnt know that?

alexfernandez commented 6 months ago

Oh, you are right! I don't use TypeScript so I have not found this issue. Care to send a patch to update index.d.ts?

pquerner commented 6 months ago

Mh I dont really know how. I will investigate if I do this right. Maybe some other typescript user here? ^^

I tried npx -p typescript tsc lib/**/*.js --declaration --allowJs --emitDeclarationOnly --outFile index.d.ts but the git diff is really scary big.

diff.txt

from: https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html