BOLL
Possible to use Deno.test for callbacks?
I've been implementing tests to make sure the porting of my main project to Deno is working out as expected, coupled with this is a WebSocket server done with
Deno.serve
. For this the test needs to handle both a server and client session, waiting for callbacks to come through.
Right now my test finishes prematurely even if I await the termination of the server, I need to set both sanitizeOps: false
and sanitizeResources: false
to have the test finish at all, but then it skips any assert
defined in the callbacks.
My previous experience is with Mocha where we get the done
callback to run to finish the current test, but for Deno.test
I only see us getting the option to make the test caller asynchronous, which in this case doesn't seem to help me.
Basically, is it possible to have something like this working:
My problem now is as mentioned that the callbacks will happen at arbitrary points in time and aren't made to be awaited, so they won't be blocking the test from finishing.
I can see adding a few more options to the test options object, like awaitDone
and timeout
, to enable running until manually marked as done or failing when timing out. To finish a test Deno.TestContext
could have a .done()
method on it. Unless this already exists, but I haven't found how to achieve this in the docs or in the types, yet.
The simulated example but with the above suggestion:
7 replies
Run Fresh in subfolder with root deno.json
I'm using Fresh in a project where I have a big pile of other code in a separate folder. It works running the project if I have the
deno.json
file in the Fresh folder, but then formatting etc won't apply to code in the other folder.
Considering this, I am trying to get workspaces working, but I'm kind of stuck. If I make a root file and try to include Fresh as a workspace, the imports in it then fails due to not having been prefixed with ./
or ../
, if I move the imports to the root deno.json
I get an error that the Fresh deno.json
requires imports to be in there to run at all, but then those would override the ones in the root. I'm getting very confused by all of this.
Is it even possible to have a Fresh instance as a workspace folder? I'm basically looking to do the below, and I'm struggling to keep my sanity:
But yeah, I'm kind of at a moment 22 here and not sure how to get that to work. If possible I want to have separated imports between fresh
and other
, thus why it's split up like this, but again I'm struggling to actually get Fresh to work while in a workspace.7 replies
Deno workspaces and Fresh, a viable combination?
Hello! I'm attempting to port an existing project to Deno and Fresh. I'm still working on the initial setup, and I have a structure like this:
I want to separate the code to port and the Fresh installation as one will be ripped apart and the other should already be functional, and figured I could use
workspace
to join everything up, but I'm struggling to get it to work.
First off, the workspace for lib
cannot have a name, as there is not one file but a range of files to reference. Do I need to create an index.ts
file in there to reference to make this work at all? I already have a generator for that so should be possible but it'll be a large one. I want this so I can reference the stuff in there without the eventual ../../../lib/###
.
If I remove the name from the subfolder deno.json
, the error for missing a file goes away, but instead I get this error from the Fresh installation:
Is using workspaces with Fresh even a reasonable approach at this point in time, or should I try to move the Fresh deno.json to my root folder and run it all from there? I mostly want it there so scripts can be executed from the root of the project, but maybe that is just wishful thinking.
Thinking about it now it feels like I should just leave the deno.json
in the ./server
folder, hopefully the compile settings will still apply to the other folders for the language server even if they are a level outside.
There's many things I'm unsure of here, but figured I could leave a post here with my musings, I'll be back tomorrow 😅 This is so I can sleep after having spent many hours trying to make sense of Fresh today, sadly I'm not that fresh myself so it's been slow going!4 replies
PHPStorm (JetBrains) needs restart of LSP server to pick up on code changes, fact of life?
I saw in the only other post showing up for
JetBrains
that the plugin is apparently not where it should be, I take it that is why I have to constantly restart the LSP server for the linting to actually pick up on my code changes, possibly when it has to do with imports and/or file name changes.
I'm converting an old project now and fixes I do don't get registered without this LSP server restart, but then I am doing some pretty substantial refactoring.
It hampers the transition to Deno quite a bit for me personally so I'm checking if others are experiencing the same, and if there is an easy fix for this or not. Otherwise I guess the place to talk about this would be in JetBrains issue tracker yeah? 😅
I will stick to Deno in any case, I adore that I can run TypeScript directly, and I won't let that go 😌
(For posterity: PHPStorm 2024.1, Deno plugin 241.17011.2)1 replies