question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TestCafe Invalid destructuring assignment target

See original GitHub issue

Describe the bug We are using TestCafe to do our e2e tests and when we do a simple test we are getting a weird error. We would like to ask for your help on what this could mean. When we compile the app both in development and in production everything works fine but as soon as we try to start testing using testcafe, it doesn’t let us proceed. Any idea what this could be?

To Reproduce Steps to reproduce the behavior:

  1. Go to https://github.com/DiogoBatista/react-hook-form-test-cafe
  2. Clone it and install it
  3. run yarn start
  1. run yarn run e2e in a separate terminal
  1. See error

Expected behavior It shouldn’t give an error on the react-hook-form library

Screenshots Screenshot 2020-02-10 at 16 39 53

import React from "react";
import logo from "./logo.svg";
import { useForm } from "react-hook-form";

import "./App.css";

const App = () => {
  const { control } = useForm();
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.tsx</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
};

export default App;

Desktop (please complete the following information):

  • OS: MacOs
  • Browser chrome
  • Version 80.0.3987.87

Additional context Not sure what could be the error but it seems that the whole import of a hook is a problem. I know that this is could be related with the use of testcafe but your help would be much appreciated 🙏 I created a simple repo with a CRA app and a simple testcafe test to demonstrate what I’m talking about. Thank you for you support and keep up the good work!!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
Kryshtopenkocommented, Mar 12, 2020

Workaround.

  1. Install next dependencies to your project: npm i -D @babel/core @babel/plugin-transform-runtime @babel/preset-env

  2. Add { test: /\.(js)$/, exclude: [/node_modules\/(?!(react-hook-form)\/).*/], use: [ { loader: "babel-loader" } ] }, as rule to your webpack.common.ts.

  3. Create babel.config.json { "presets": [ [ "@babel/preset-env", { "modules": "commonjs" } ] ], "plugins": [ [ "@babel/plugin-transform-runtime" ] ] }

Enjoy.

2reactions
lvwrencecommented, Feb 11, 2020

fyi, i got alerted to similar error on prod on latest chrome (Chrome 80.0.3987)

TypeError
Invalid attempt to spread non-iterable instance

at this line:

const { register, handleSubmit, errors } = useForm()

Also, it seems like user was using google translate on the page, so might be related to https://github.com/react-hook-form/react-hook-form/issues/985?

will try to repro locally.

btw, thanks for the library! it’s super useful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting error: "Uncaught SyntaxError: Invalid destructuring ...
Uncaught SyntaxError: Invalid destructuring assignment target. My code: let duplication = ([1,2,3,4,5]) => {this.concat(this)};.
Read more >
Invalid Destructuring assignment target?? Can anyone point ...
I am getting Uncaught SyntaxError: Invalid destructuring assignment target on the console and nothing runs. Appreciate help! // 1. Create a ...
Read more >
Invalid destructuring assignment target Error in JavaScript
The "Invalid destructuring assignment target" error occurs when we make a syntax error when declaring or destructuring an object, often in the arguments ......
Read more >
Use error in ava With Examples | LambdaTest
How to use error method in ava · Run ava automation tests on LambdaTest cloud grid · Accelerate Your Automation Test Cycles With...
Read more >
Ultimate List of JavaScript Interview Questions - Soshace
What is wrong with this code? ... Give code samples for immutable operations using Object.assign and Spread operator ... What is a destructuring...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found