# How to test?

There are a couple ways to test your module:

{% tabs %}
{% tab title="With node on PC" %}
You can use node to test your scripts, to install node head over to their [official install page](https://nodejs.org/en/download).

To test your script, run node in your command line program:

{% code lineNumbers="true" %}

```
> node {PATH TO FILE}
```

{% endcode %}

For example:

{% code lineNumbers="true" %}

```
> node /Users/Test/Downloads/example.js
```

{% endcode %}

To log any constants or errors, you can for example use:

{% code title="Example logging of a constant" lineNumbers="true" %}

```javascript
console.log('Raw output:', response);
```

{% endcode %}

{% code title="Ouput:" lineNumbers="true" %}

```
> node /Users/Test/Downloads/example.js
Raw output: example response
```

{% endcode %}

{% code title="Example logging of an error" lineNumbers="true" %}

```javascript
const value = 10;

if (value > 20) {
    console.log("Value is greater than 20.");
} else {
    console.error("Error: Value is not greater than 20.");
}
```

{% endcode %}

{% code title="Output" lineNumbers="true" %}

```
> node /Users/Test/Downloads/example.js
Error: Value is not greater than 20.
```

{% endcode %}

To add an example input (testing regex or fetching for example), use:

{% code title="Example input" lineNumbers="true" %}

```javascript
function search(html){
// Some code
}

search(`html or something idc`); 
// WARNING: Use backticks for multi line inputs!
```

{% endcode %}

{% code title="Example of an async code" lineNumbers="true" %}

```javascript
async function search(keyword){
const response = await fetch(`https://google.com/${keyword}`)
}

search(`I hate my life`); 
```

{% endcode %}

{% hint style="info" %}
WARNING:

When testing on PC, you will need to use .json() and .text() methods instead of JSON.parse() and directly applying the value! Only replace those methods when you want to actually test on phone!
{% endhint %}
{% endtab %}

{% tab title="In browser" %}
Huge thanks to @[JMcrafter26](https://github.com/jmcrafter26) for making this website, it simulates Sora's frontend, a great way to quickly test your modules on PC in case you don't own a Mac.\
\
The website and FAQ can be found here: <https://api.jm26.net/sora-modules/>
{% endtab %}

{% tab title="With Sora on Mac" %}
Get the Sora app for Mac from [here](https://github.com/cranci1/Sora/releases/download/0.2.0/Sora-maccatalyst.zip).

This is the fastest way to test it in the app, seeing as Github raw often takes some time to update it's faster to directly edit the Sora cached modules.

To add the module to the app, host your java script file and JSON on your preferred file hoster (needs to support viewing the raw file), it is recommended to use GitHub.

Once you've hosted the file, you will need to copy the raw link of the java script file and add it to your JSON, after doing this you will need to copy the raw link of your JSON, which will look something like this:

```
https://raw.githubusercontent.com/50n50/maisgay/refs/heads/main/hianime/hianime.json
```

To find the cached scripts, head over to this file path on your Mac:

```
/Users/[Your username]/Library/Containers/me.cranci.Sora/Data/Documents/
```

You will find all the modules there, unfortunately they will have some gibberish name so you will need to which is the one you want to edit. Once you've found it you can easily edit anything you want and restart the Sora app to quickly test the changes.
{% endtab %}

{% tab title="Testing in Sora" %}
{% hint style="info" %}
The Sora logger is pretty bad, so it is recommenced to test on PC first if you want proper logs!
{% endhint %}

To test in Sora, you will obviously need to first sideload the app, join the official discord for help if needed!

To add the module to the app, host your java script file and JSON on your preferred file hoster (needs to support viewing the raw file), it is recommended to use GitHub.

Once you've hosted the file, you will need to copy the raw link of the java script file and add it to your JSON, after doing this you will need to copy the raw link of your JSON, which will look something like this:

{% code lineNumbers="true" %}

```
https://raw.githubusercontent.com/50n50/maisgay/refs/heads/main/hianime/hianime.json
```

{% endcode %}

Please make sure you are copying the raw link!

After making modifications, remove the module from Sora and restart to app before re-adding it!

{% hint style="info" %}
WARNING:&#x20;

When testing in Sora, replace all .text() and .json() methods like noted before!
{% endhint %}
{% endtab %}
{% endtabs %}
