# Molid - A mock solid server for local testing

**URL:** <https://forum.solidproject.org/t/molid-a-mock-solid-server-for-local-testing/2447>\
**Category:** Developer Experience\
**Created:** [November 23, 2019, 11:16am UTC](https://forum.solidproject.org/t/molid-a-mock-solid-server-for-local-testing/2447 "2019-11-23T11:16:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [November 23, 2019, 11:16am UTC](https://forum.solidproject.org/t/molid-a-mock-solid-server-for-local-testing/2447/1 "2019-11-23T11:16:20Z")

</div>

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.

[https://www.npmjs.com/package/molid](https://www.npmjs.com/package/molid)

## Quick start 🚀

Start using `npx`, no installation needed

```auto
npx molid

```

> Molid - mock Solid server listening on port 3333!

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

```auto
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](https://www.npmjs.com/package/molid#usage-within-your-solid-app-project)

## 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:

> **[Angelo Veltens / Molid - Mock Solid Server · GitLab](https://gitlab.com/angelo-v/molid-mock-solid-server)**
>
> A mock server that can be used for testing Solid apps locally

---

<div class="post-metadata">

**Author:** ![A\_A](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/a_a/32/786_2.png) [@A\_A](https://forum.solidproject.org/u/A_A)\
**Post date:** [November 25, 2019, 7:52am UTC](https://forum.solidproject.org/t/molid-a-mock-solid-server-for-local-testing/2447/2 "2019-11-25T07:52:47Z")

</div>

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](https://github.com/jeff-zucker/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](http://forum.solidproject.org/t/local-solid-pod/2351) about [solid-local-pod](https://github.com/otto-aa/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.

---

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [November 27, 2019, 8:19pm UTC](https://forum.solidproject.org/t/molid-a-mock-solid-server-for-local-testing/2447/3 "2019-11-27T20:19:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [December 12, 2019, 9:05pm UTC](https://forum.solidproject.org/t/molid-a-mock-solid-server-for-local-testing/2447/4 "2019-12-12T21:05:41Z")

</div>

I just **released version 0.2.0** 🎉 with some brand new _features_ and a shiny and extended _[documentation](https://molid.readthedocs.io/)_.

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

Try the givenMolid-block for Jest:

```javascript
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');
        });
    });
});

```

📖 Read the full docs:

[https://molid.readthedocs.io/](https://molid.readthedocs.io/)

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [December 14, 2019, 1:38am UTC](https://forum.solidproject.org/t/molid-a-mock-solid-server-for-local-testing/2447/5 "2019-12-14T01:38:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [December 14, 2019, 2:28pm UTC](https://forum.solidproject.org/t/molid-a-mock-solid-server-for-local-testing/2447/6 "2019-12-14T14:28:48Z")

</div>

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](https://github.com/otto-aa/solid-local-pod) is going into the direction you are looking for. Molid will stay focused on testing / mocking purposes.

---

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [April 22, 2020, 7:24am UTC](https://forum.solidproject.org/t/molid-a-mock-solid-server-for-local-testing/2447/7 "2020-04-22T07:24:53Z")

</div>

I published [Molid 0.3.0-beta](https://gitlab.com/angelo-v/molid-mock-solid-server/-/releases/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.
