Skip to content
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

Test argument "title" should be a string. Received type "object" #233

Open
AndrewAvalos opened this issue Oct 13, 2022 · 0 comments
Open

Comments

@AndrewAvalos
Copy link

AndrewAvalos commented Oct 13, 2022

Hello, I am having trouble getting cypress-tags to work properly in my project. I've reviewed and tried everything from the previous related issue #21 but unfortunately nothing seems to work.

"cypress-tags": "1.1.2",
"@cypress/webpack-preprocessor": "5.11.1",
"cypress": "10.10.0",

Test Command:

CYPRESS_INCLUDE_TAGS=wip CYPRESS_BASE_URL=https://www.qa.truecardev.com/ npx cypress run --spec=cypress/e2e/dealer/dealerPortal.spec.ts

returns 

  0 passing (887ms)
  1 failing

  1) An uncaught error was detected outside of a test:
     TypeError: The following error originated from your test code, not from Cypress.

  > Test argument "title" should be a string. Received type "object"

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.

Spec File snippet

context("Dealer Portal end to end tests", () => {
  it(
    ["wip"],
    "login as a dealer admin and create manual offer for new vehicle",
    () => {
      cy.visit("/")
    })
  })

cypress.config.ts snippet:

import { defineConfig } from "cypress";
import webpack from "@cypress/webpack-preprocessor";
import aliases from "./webpack/aliases";
import appRootPath from "app-root-path";
import path from "path";
import del from "del";
import { tagify } from "cypress-tags";

export default defineConfig({
  e2e: {
    // We've imported your old cypress plugins here.
    // You may want to clean this up later by importing these.
    setupNodeEvents(on, config) {
      on("file:preprocessor", tagify(config));

      on(
        "file:preprocessor",
        webpack({
          webpackOptions: {
            module: {
              rules: [
                {
                  test: /\.mjs$/,
                  include: /node_modules/,
                  exclude: [/browserslist/],
                  type: "javascript/auto",
                  // Prevent an error from graphql-js
                  // https://github.com/graphql/graphql-js/issues/2721
                  resolve: {
                    fullySpecified: false,
                  },
                },
                {
                  test: /\.tsx?$/,
                  exclude: [/node_modules/],
                  use: [
                    {
                      loader: "babel-loader",
                      options: {
                        presets: [
                          "@babel/preset-env",
                          "@babel/preset-react",
                          "@babel/preset-typescript",
                        ],
                        babelrc: false,
                      },
                    },
                  ],
                },
                {
                  test: /\.js?$/,
                  exclude: [/node_modules/],
                  use: [
                    {
                      loader: "babel-loader",
                      options: {
                        presets: ["@babel/preset-env"],
                        // our generated graphql operation files mix commonjs and ESM syntax,
                        // convert to commonjs to avoid "ES Modules may not assign module.exports or exports.*" error
                        plugins: ["@babel/plugin-transform-modules-commonjs"],
                        babelrc: false,
                      },
                    },
                  ],
                },
              ],
            },
            resolve: {
              extensions: [".js", ".ts", ".tsx", ".json", ".mjs"],
              alias: Object.assign({}, aliases, {
                elasticsearch: "elasticsearch-browser",
                requests: path.resolve(
                  appRootPath.toString(),
                  "cypress",
                  "requests",
                ),
                fixtures: path.resolve(
                  appRootPath.toString(),
                  "cypress",
                  "fixtures",
                ),
                pages: path.resolve(appRootPath.toString(), "cypress", "pages"),
              }),
            },
          },
        }),
      );

      on("task", {
        log(message) {
          // eslint-disable-next-line no-console
          console.log("        Log Message:", message);
          return null;
        },

        table(message) {
          // eslint-disable-next-line no-console
          console.table(message);

          return null;
        },
      });

      on("after:spec", async (spec, results) => {
        if (results && results.video) {
          // Do we have failures for any retry attempts?
          const failures =
            results.tests &&
            results.tests.some(test =>
              test.attempts.some(
                attempt => attempt && attempt.state === "failed",
              ),
            );
          if (!failures) {
            // delete the video if the spec passed and no tests retried
            await del(results.video);
          }
        }
      });

    },
  },
});

My guess is that webpack might be causing some compatibility issues. Thank you for any help!

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

No branches or pull requests

1 participant