You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I go to localhost:1337/admin to tick the "find" action against the hello endpoint for "public" roles, so I can get the expected "hello world" from localhost:1337/api/hello. But the test case still failed due to it's reading test config.
Could we update the doc on how to make the test pass?
Additional context
[2023-12-04 11:36:01.033] http: GET /api/hello (27 ms) 403
FAIL tests/app.test.js (8.259 s)
✓ strapi is defined (4 ms)
✕ should return hello world (94 ms)
● should return hello world
expected 200 "OK", got 403 "Forbidden"
5 | await request(strapi.server.httpServer)
6 | .get("/api/hello")
> 7 | .expect(200) // Expect response http code 200
| ^
8 | .then((data) => {
9 | expect(data.text).toBe("Hello World!"); // expect the response text
10 | });
at Object.expect (tests/hello/index.js:7:6)
----
at Test._assertStatus (node_modules/supertest/lib/test.js:252:14)
at node_modules/supertest/lib/test.js:308:13
at Test._assertFunction (node_modules/supertest/lib/test.js:285:13)
at Test.assert (node_modules/supertest/lib/test.js:164:23)
at Server.localAssert (node_modules/supertest/lib/test.js:120:14)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 passed, 2 total
Snapshots: 0 total
Time: 8.589 s, estimated 9 s
Ran all test suites.
error Command failed with exit code 1.
Suggested improvements or fixes
Either fix the doc on Test to set up the test config to allow the hello endpoint be public, or fix the doc in Controllers to make it public by default.
Related issue(s)/PR(s)
No response
The text was updated successfully, but these errors were encountered:
Hi,
Thanks for reporting. I'm closing this issue, but it's included in the meta issue about reworking the Testing page (#1940).
In the meantime I'll check with Strapi engineers to see if they can come up with a solution.
Link to the documentation page or resource
https://docs.strapi.io/dev-docs/testing#test-a-basic-endpoint-controller
Describe the bug
I refer to the the doc to create a test case against the
/api/hello
endpoint. And also created the endpoint followed https://docs.strapi.io/dev-docs/backend-customization/controllers.But the test case failed by 403.
So I go to localhost:1337/admin to tick the "find" action against the hello endpoint for "public" roles, so I can get the expected "hello world" from localhost:1337/api/hello. But the test case still failed due to it's reading test config.
Could we update the doc on how to make the test pass?
Additional context
Suggested improvements or fixes
Either fix the doc on Test to set up the test config to allow the hello endpoint be public, or fix the doc in Controllers to make it public by default.
Related issue(s)/PR(s)
No response
The text was updated successfully, but these errors were encountered: