Skip to content

feat(test:e2e): specify command to run for tests #5214

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Ob-La-Di
Copy link

@Ob-La-Di Ob-La-Di commented Feb 24, 2020

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

vue-cli-service currently run a normal serve command for end to end test. This is an issue for people who use a custom command as explained here. This PR adds the possibility to pass a custom command to run instead of the default serve.

Example:

package.json

  "vuePlugins": {
    "service": [
      "vue-cli.test.js"
    ]
  }

vue-cli.test.js

const webpack = require('webpack');

module.exports = (api) => {
  api.registerCommand('serve:async', async (args) => {
    
    const result = await someAsyncFunction();

    api.chainWebpack((config) => {
      config.plugin('defineFoo').use(
        new webpack.DefinePlugin({
          FOO: JSON.stringify(result),
        }),
      );
    });

    // it's important to return the result here
    return api.service.run('serve', args);
  });
};

We need to define a global variable FOO to run build for production, but running vue-cli-service test:e2e fails because FOO will not be defined. This PR fixes the issue by running vue-cli-service test:e2e --command serve:async

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants