Otacon6530

Veteran
Veteran
Joined
Apr 12, 2022
Messages
32
Reaction score
20
First Language
English
Primarily Uses
RMMV
I spent a week trying to get a decent setup in visual studio 2022 for my plugin development, but have been encountering issues at every step (as usual).

Here is what I have been able to accomplish:

  • Created node project
  • setup the start (f5) to launch the game from nw.js.
  • Tried to Setup basic mocha test in vs, but cant use it because rpgmaker uses the dom.
  • Tried to Setup mocha to run from nw.js, but it cant find my required object. E.g. chai
The question is

  • How did you setup the build and start buttons?
  • How did you run unit and integration testing?
  • Have any general advice on setting this up in vs?
 

Otacon6530

Veteran
Veteran
Joined
Apr 12, 2022
Messages
32
Reaction score
20
First Language
English
Primarily Uses
RMMV
Ok, this is what I was able to do to for the next person that wants to setup VS pro for Plugin development:

  • Create a react solution of the game files.
  • Set the start external program setting to use NW.js and setup the command line arguments to point to your project folder (--nwapp). This will make it so you can start the game from VS.
1653710001848.png
JavaScript:
 this.mochaDiv.id = 'mocha';
    document.body.appendChild(this.mochaDiv);
    loadScript('node_modules/mocha/mocha.js', function () {
        loadScript('test/appTest.js', function () {
        });
    });
};

function loadScript(url, callback) {
    // Adding the script tag to the head as suggested before
    var head = document.head;
    var script = document.createElement('script');
    script.type = 'module';
    script.src = url;

    // Then bind the event to the callback function.
    // There are several events for cross browser compatibility.
    script.onreadystatechange = callback;
    script.onload = callback;

    // Fire the loading
    head.appendChild(script);
}
 

if (this.doc == null) {
        document.getElementById('errorPrinter').appendChild(this.mochaDiv);
        document.getElementById('errorPrinter').removeChild(this.mochaDiv);
        var divText = this.mochaDiv.outerHTML;
        var myWindow = window.open('', '', 'height=500,width=500,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes');
        var doc = myWindow.document;
        doc.open();
        doc.write(divText);
        doc.close();

        // Create new link Element
        var link = doc.createElement('link');

        // set the attributes for link element
        link.rel = 'stylesheet';
        link.type = 'text/css';
        link.href = 'node_modules/mocha/mocha.css';

        // Get HTML head element to append
        // link element to it
        doc.getElementsByTagName('HEAD')[0].appendChild(link);

        this.doc = doc;
    }
this.mochaDiv = document.createElement('div');

This is what it looks like after I hit run. You can see the mocha tests in the left popup window.

1653710697666.png

Here is the test code:
JavaScript:
const assert = require('chai').assert;
mocha.ui('bdd').run(function (failures) {
    process.on('exit', function () {

        process.exit(failures);
    });
});

describe('App', function () {
    it('app should return hello', function () {
        assert.equal('a','a');
    });
})
 
Last edited:

Latest Threads

Latest Profile Posts

Enig and Riley.png
Each area of my game acts sort of like a level of sorts. These 3 are the bosses of the first area. Called Team Outcast, there's Riley, Mary Mars McQueen (Triple M), and Enig. A trio of wanna be super heroes.
hQopibt.gif

Now with animated hair~
This could be useful...
I made a menu option that pulls a (accurate) version of the world map from my game instead of having a "traditional" world map. How did I do?

1656552400614.png

..Every time after I edit it and repost it I find a new tiny error I made. :kaodes:
1656550526125.png
Town Design is the best part of an RPG. Well, that and dungeon design

Forum statistics

Threads
123,191
Messages
1,154,715
Members
161,560
Latest member
evanjocobs
Top