Molid - A mock solid server for local testing

When building Solid apps I was in need of a dummy server that just returns some data that I can easily adjust while developing an app - without setting up a real pod and without having to rely on a internet connection.

That’s why I built Molid, a very simple mock server that is able to serve fake linked data for local app development.

Quick start :rocket:

Start using npx, no installation needed

npx molid

Molid - mock Solid server listening on port 3333!

Molid provides some Solid data, that you can now access via HTTP, e.g.

curl http://localhost:3333/profile/card

All the mock data is stored within the .molid folder in your current directory. Adjust it to your needs and restart.

Usage within your Solid app project

See Readme

Is this useful for you?

Please let me know if this helps you too developing solid app! I know it is very limited for now. Feel free to open an issue and requests features you need for your app development.

If you have any questions, I am happy to help.

Source Code

Of course Molid is fully open source:

15 Likes

Thanks for sharing this with us, I think that mock servers can be pretty useful for developing. I wonder how it compares to other tools for that I know of.

In the update of solid-file-client we currently use solid-auth-cli to test all fetch methods. solid-auth-cli provides a fetch method which accepts app://ls/foo/bar urls for in-memory storage of a pod, file://foo/bar urls for using the file storage as a pod, and http[s] urls for using a remote (or localhost) pod. In our case we setup a test folder in the memory/file storage and then run our tests against it.
Advantages I see compared to Molid: can programmatically create test setup. can use GET/POST/DELETE/… requests. good for unit tests
Disadvantages: requires the app to use the solid-auth-cli fetch method. some setup is nice to have (if there is interest I can extract our setup logic into a separate package. It includes a TestFolderGenerator for creating and resetting folders)

Also, I’ve recently made a post here about solid-local-pod, which does pretty much the same thing as molid as far as I see. You can run parts of your filesystem as a localhost pod, supporting GET/DELETE/POST/…, but no authentication. So I’d be interested what the differences to molid would be. I guess starting it is slightly more complicated, though I don’t think that would be an obstacle to use it.

3 Likes

Hi @A_A, thanks for sharing this, I wasn’t really aware of the alternatives, and so I cannot fully overlook the pros and cons here. But I am really glad that things are moving forward regarding those topics.

solid-local-pod really looks great! Molid is very similar to that in the current stage of development but the main focus is different and so I guess both will evolve differently. If I see it correctly solid-local-pod is mainly about serving the local file system as a solid pod. So you could even use it for your real data that you want to keep local and are not willing to put online.

Molid also reads data from the local file system, but it’s main focus is being a mock server for testing. The data from file system is only used to intialize the server state. Molid will support updates eventually, but will never change those files, just it’s internal state for the duration of a testing session. It is used to have a controlled and reproducable environment for manual and automated tests. Also the app under test can always do a real HTTP request and does not have to rely on file:// or app:// schema or any specific library to use.

3 Likes

I just released version 0.2.0 :tada: with some brand new features and a shiny and extended documentation.

Molid 0.2.0 allows you to automatically start and stop instances, which makes it great for integration testing :test_tube:

Try the givenMolid-block for Jest:

import { givenMolid } from 'molid/lib/molid-jest';
import { loadProfile } from './your-code';

describe('using the givenMolid function', () => {
    givenMolid('with a profile of a person called John', molid => {
        it('successfully fetches the profile document', async () => {
            const webId = molid.uri('/profile/card#me');
            const profile = await loadProfile(webId);
            expect(profile.name).toEqual('John');
        });
    });
});

:open_book: Read the full docs:

https://molid.readthedocs.io/

6 Likes

Your project is very interesting !
It could help everyone to be his own provider.
Let’s see the .molid folder as a ‘MyDocuments’ folder stored on your computer. With the Molid server accessible on a determined port opened on your machine.
When you log in a remote Solid Webapp, the app could access Molid server and interact with your local data… Do you think it could be possible?

Hi, could be possible, but this is not what Molid is intended for, and I won’t recommend it. It’s a mock server, it’s read-only at the moment (and will not overwrite data in the .molid folder in the future) and it does not have any authorization. So any app would be able to read the data.

I think solid-local-pod is going into the direction you are looking for. Molid will stay focused on testing / mocking purposes.

1 Like

I published Molid 0.3.0-beta with limited support for LDP containers and 404 responses.

  • non-empty folders get imported as LDP containers
  • non-existing resources now return 404 instead of an empty document

Feel free to install and try it by npm install molid@beta

I will test it myself within my projects and release it as version 0.3.0 in near future, if nothing is found/reported.

5 Likes