https://supertokens.com/ logo
Creating a node PR
i

IaS1506

04/20/2023, 4:46 PM
Hi @rp, my work colleague wrote to you today about creating a PR for the config I made all the necessary changes, passed all the tests. Are there any specific instructions which I need to follow to create a PR in supertokens-node correctly? Thank you
r

rp

04/20/2023, 5:09 PM
Hey @IaS1506 you can just create a PR to our master branch. Ill point out if anything missing / wrong.
i

IaS1506

04/20/2023, 5:12 PM
Ok
Failed only 6 tests depends on credentials for apple provider

https://cdn.discordapp.com/attachments/1098650966787620934/1098663935156179105/2023-04-20_203738.png

https://cdn.discordapp.com/attachments/1098650966787620934/1098663935416209408/2023-04-20_203724.png

r

rp

04/20/2023, 5:38 PM
ah right. We will test it ourselves as well.
i

IaS1506

04/20/2023, 5:38 PM
with this

https://cdn.discordapp.com/attachments/1098650966787620934/1098664090429313086/image.png

r

rp

04/20/2023, 5:39 PM
right. That's OK.. we will run the tests on our end
i

IaS1506

04/20/2023, 5:41 PM
ok(1 thousand+ tests, you are cool)
r

rp

04/20/2023, 5:41 PM
what we have over 1k tests? i don't think so
i

IaS1506

04/20/2023, 5:42 PM
why not
r

rp

04/20/2023, 5:45 PM
hmm! cool
i

IaS1506

04/20/2023, 5:48 PM
so, should i pr all this generated from build-pretty files or only ts js and d.ts files?

https://cdn.discordapp.com/attachments/1098650966787620934/1098666490208722974/image.png

r

rp

04/20/2023, 5:49 PM
the build files as well.
r

rp

04/21/2023, 5:22 AM
thanks. Will see.
i

IaS1506

04/21/2023, 7:12 AM
Good afternoon, I have updated PR
Good evening, I have updated PR again
But dont know how to write tests in your system (commented about it)
r

rp

04/21/2023, 4:55 PM
ok so the code changes look fine now
you can add tests by looking at examples. Here are a few: https://github.com/supertokens/supertokens-node/blob/master/test/config.test.js
i

IaS1506

04/21/2023, 5:08 PM
And how to run one concrete test
not all
r

rp

04/21/2023, 5:09 PM
you can do
it.only(...)
i

IaS1506

04/21/2023, 5:10 PM

https://cdn.discordapp.com/attachments/1098650966787620934/1099019268848357458/image.png

r

rp

04/21/2023, 5:11 PM
at the very first line, there is
it(..
, change that to
it.only(...
to run just this test
also, you might wanna add a test that when a session is created, the resulting sAccessTokens' cookie path is the custom one that you had set.
i

IaS1506

04/21/2023, 5:12 PM
I get this bc in one terminal i started testing env

https://cdn.discordapp.com/attachments/1098650966787620934/1099019907607302284/image.png

And want to run in another console only this test
How to run it from console
r

rp

04/21/2023, 5:13 PM
whats the command you are running for tests?
Go into
superotkens-node
folder, and run
INSTALL_PATH=../supertokens-root npm test
i

IaS1506

04/21/2023, 5:14 PM
it run all tests
but how to run concrete file
r

rp

04/21/2023, 5:15 PM
as i said, change the code to do
it.only(..
instead of
it
i

IaS1506

04/21/2023, 5:17 PM
aa? okey
I see
Thanks, i am stupid
Hmmm
new NormalisedURLPath("/") is setting to ' '
r

rp

04/21/2023, 5:28 PM
then maybe there is some bug
try to figure it out 🙂
i

IaS1506

04/21/2023, 5:28 PM
Changed: new NormalisedURLPath("/") is setting to ' '
r

rp

04/21/2023, 5:28 PM
yea, that's expected
i

IaS1506

04/21/2023, 5:29 PM
{ STExpress.init({ supertokens: { connectionURI: "http://localhost:8080", }, appInfo: { apiDomain: "api.supertokens.io", appName: "SuperTokens", websiteDomain: "supertokens.io", }, recipeList: [Session.init({ getTokenTransferMethod: () => "cookie" })], }); console.log( "Path: ", SessionRecipe.getInstanceOrThrowError().config.accessTokenPath.getAsStringDangerous() ); assert(SessionRecipe.getInstanceOrThrowError().config.accessTokenPath.getAsStringDangerous() === "/"); resetAll(); }
for this i get not passed
r

rp

04/21/2023, 5:29 PM
yea, cause
SessionRecipe.getInstanceOrThrowError().config.accessTokenPath.getAsStringDangerous()
should be equal to
""
that's why when setting the actual cookie path, we check if it's equal to
""
and if it is, we set it to
"/"
instead
i

IaS1506

04/21/2023, 5:31 PM
Yeah, I have two tests: when set and not
when set is good
r

rp

04/21/2023, 5:31 PM
yea.. so when not set, it should be equal to
""
and not
"/"
i

IaS1506

04/21/2023, 5:31 PM
ahh, ok
will deploy it now
r

rp

04/21/2023, 5:32 PM
you should also add a test where you actually call an API to create a session and see that the path of the access token is correctly set
(based on your config)
you can see other tests where similar operaiton is happening
i

IaS1506

04/21/2023, 5:36 PM
like this await Session.createNewSession(mockRequest(), mockResponse(), "userId");
?
r

rp

04/21/2023, 5:37 PM
no..
i

IaS1506

04/21/2023, 5:38 PM
🥲
i

IaS1506

04/21/2023, 5:44 PM
Maybe I am slowpoke, but where should i check it Like SuperTokens.init({ supertokens: { connectionURI: "http://localhost:8080", }, appInfo: { apiDomain: "api.supertokens.io", appName: "SuperTokens", websiteDomain: "supertokens.io", }, recipeList: [Session.init({ getTokenTransferMethod: () => "cookie", antiCsrf: "VIA_TOKEN" })], }); const app = express(); app.use(middleware()); app.post("/create", async (req, res) => { await Session.createNewSession(req, res, "", {}, {}); res.status(200).send(""); }); app.get(accesstokenpath_here, async (req, res) => { ...... })
r

rp

04/21/2023, 5:44 PM
after calling the create API
see that the result has cookie for sAccessToken
and the path of that is as per your setting
i

IaS1506

04/21/2023, 5:45 PM
aaaaa
okey, thanks
No param for access token path

https://cdn.discordapp.com/attachments/1098650966787620934/1099031962636783627/image.png

😭
r

rp

04/21/2023, 6:01 PM
See this function: https://github.com/supertokens/supertokens-node/blob/811220bfd6679c40e3664687e5c086b18b1fa073/test/utils.js#L81 Instead of calling that function in your test, manually get the
sAccessToken
and see the path from that string
i

IaS1506

04/21/2023, 6:06 PM
A
Good
(please forgive me for this long dialog)
r

rp

04/21/2023, 6:14 PM
no worries 🙂
i

IaS1506

04/21/2023, 6:43 PM
pushed tests
r

rp

04/22/2023, 2:42 PM
hey @IaS1506 i have released the new SDK version with your PR. It's version 13.5.0
i

IaS1506

04/22/2023, 2:43 PM
🥰 👍
r

rp

04/22/2023, 2:43 PM
thank you for the work 🙂