Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
Js: I have this error while I try to build a Cypress test "FileField is not a constructor"

I have to try to create some test usen js Composition, I'm following this article: https://www.koderhq.com/tutorial/javascript/composition/#what-is

I have a js class

class FileField {

  constructor () {

  }
  /**
   * Upload file to file field.
   *
   * @param {string} InputAttribute
   * @param {string} url
   * @param {string} AltAttribute
   */
  uploadField(InputAttribute, url, AltAttribute ) {}
}
export default {FileField}

And I try to use this class in this way in another class:

import { DefaultContent } from "./DefaultContent/DefaultContent";
import { PROPERTY } from "./DefaultContent/DefaultContent";
import { FileField } from "./DefaultContent/FileField";

export default class ArticlePage extends DefaultContent {
  constructor(FileField) {
    this.fileField = new FileField();
  }

  fillImageField() {

    // Upload the file
    this.fileField.uploadFile(
      this.imageInput,
      "/node/add/article?element_parents=field_image/widget/0&ajax_form=1&_wrapper_format=drupal_ajax",
      this.imageAltDescription,
      );
   }
}

I get the error: > FileField is not a constructor

enter image description here

I have checked articles and StackOverflow questions but none works with my code.

Thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!