Skip to content

Add Launch Config Snippet for Pester Tests? #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rkeithhill opened this issue Feb 6, 2017 · 9 comments
Closed

Add Launch Config Snippet for Pester Tests? #487

rkeithhill opened this issue Feb 6, 2017 · 9 comments
Labels
Issue-Discussion Let's talk about it.

Comments

@rkeithhill
Copy link
Contributor

I was looking at the Node.js debugger configurations, they have one for Mocha tests:

Mocha Tests: Debug mocha tests in a test folder of your project. Make sure that your project has 'mocha' installed in its node_modules folder.

I wonder if we should have a similar config snippet for debugging Pester tests?

@rkeithhill rkeithhill added the Issue-Discussion Let's talk about it. label Feb 6, 2017
@daviwil
Copy link
Contributor

daviwil commented Feb 6, 2017

A default Pester debugging config could be nice, we just might need to make sure the user understands that they'll have to change the default test path of the config if they don't have their test files under .\test or whatever we deem the default.

@rkeithhill
Copy link
Contributor Author

I think we might be able to get away with just throwing the ${workspaceRoot} at Pester and it will find and run all *.Tests.ps1 files. The user can always limit that to ${workspaceRoot}/test or ${workspaceRoot}/tests if they need to.

@daviwil
Copy link
Contributor

daviwil commented Feb 6, 2017

Good point, sounds good to me!

@rkeithhill
Copy link
Contributor Author

rkeithhill commented Feb 7, 2017

I added this and it works but works as an accident. I specify the "script": value as Invoke-Pester which is not a file path. However, this code happens to accept that:

        public async Task ExecuteScriptAtPath(string scriptPath, string arguments = null)
        {
            PSCommand command = new PSCommand();

            if (arguments != null)
            {
                // If we don't escape wildcard characters in the script path, the script can
                // fail to execute if say the script name was foo][.ps1.
                // Related to issue #123.
                string escapedScriptPath = EscapePath(scriptPath, escapeSpaces: true);
                string scriptWithArgs = escapedScriptPath + " " + arguments;

                command.AddScript(scriptWithArgs);
            }
            else
            {
                command.AddCommand(scriptPath);
            }

            await this.ExecuteCommand<object>(command, true);
        }

But this works only when there are no args as it adds the string as a command.

How should we proceed on this? I don't like the fact that args won't work. Probably the right way to make this work is add another property say command that is mutually exclusive with script but that doesn't seem like a change we should make for the upcoming release. Thoughts?

@rkeithhill
Copy link
Contributor Author

@daviwil Do you know if the changes for interactive console support will still allow a "script": arg of Invoke-Pester?

@daviwil
Copy link
Contributor

daviwil commented Feb 11, 2017

Idea: maybe we can add an additional parameter to the launch config called "command" which takes a command name then the args parameter applies to that. That parameter and "script" would be mutually exclusive.

@rkeithhill
Copy link
Contributor Author

You mean like this:

Probably the right way to make this work is add another property say command that is mutually exclusive with script but that doesn't seem like a change we should make for the upcoming release. Thoughts?

Great minds think alike. :-)

@daviwil
Copy link
Contributor

daviwil commented Feb 11, 2017

I dunt reed 2 gud ;)

If you want to make that change, go for it!

@rkeithhill
Copy link
Contributor Author

OK, have implemented this and will be submitting PRs to both this repo and PSES. Came to conclusion that we don't need a Command property. I modified the PSES launch code to verify if the "script" is a path to a file or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Discussion Let's talk about it.
Projects
None yet
Development

No branches or pull requests

2 participants