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 Posts

Latest Profile Posts

Spent all day writing code, only for it to result in an endless loop...sigh.:kaosigh:
So um what is the deal with rpgmakerofficial.com ,why are there two rpg maker websites now? Is it any different from the current one rpgmakerweb.com??
ScreenShot_7_1_2022_11_41_55.png
When the Panic gauge is full, Mike will turn into Omar in a state of actual panic. his move list changes and until the meter depletes completely, he'll be able make use of this alter ego.
So unbelievably excited for IGMC this year! First public game was for the original one and I'm just so pumped!!
Sometimes I am amazed at how relentless spam bots are. I would clear the que and then see 800~5k more depending on their mood.

Forum statistics

Threads
123,263
Messages
1,155,318
Members
161,645
Latest member
MercyTales
Top