mercredi 1 mai 2019

How to wait until vscode.windows.terminal operation is over?

When I execute a testing witch need the ending result of a vscode.windows.terminal the testing gave me a false positive. I need wait until the terminal operation end in order to execute the asserts.

I use a class named Stack witch have a pom file. My test start with the execution of cd and mvn clean install using the vscode.windows.terminal. The idea of the test assertion is verify the existence of the target file.

const buildProgram = () => {
    const terminal = vscode.window.createTerminal();
    terminal.show();
    terminal.sendText('cd ' + stackDirectory);
    terminal.sendText('mvn clean install');
}

    it("Stack Project build taget directory exists", function() {
        const promise = Promise.all([buildProgram()])
        .then(() => {
            return fs.existsSync(stackDirectory + "/target");
        });

        expect(promise).to.eventually.equal(false);
    });

This test runs without problem but in the end the target directory is not created.

Aucun commentaire:

Enregistrer un commentaire