Cypress encounters a SyntaxError while running in continuous integration due to an unexpected token 'export' with the cypress-io/github-action@v2 typescript

Within my cypress plugin file located at

frontend/cypress/plugins/index.ts
, I have the following code snippet:

export default ((on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
}) as Cypress.PluginConfig

Interestingly, when I execute this on my local machine, everything works seamlessly. However, the moment I integrate cypress-io/github-action@v2 within my GitHub actions flow, I encounter the following error:

Your pluginsFile is invalid: /home/runner/work/XX/XX/frontend/cypress/plugins/index.ts

It threw an error when required, check the stack trace below:

/home/runner/work/XX/XX/frontend/cypress/plugins/index.ts:14
export default ((on, config) => {
^^^^^^
SyntaxError: Unexpected token 'export'

Provided below is the content of my

.github/workflows/cypress-tests.yml
:

name: Cypress Tests

jobs:
  cypress-run:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
    
      - name: Install dependencies
        run: | 
          cd frontend  
          npm ci
                
      - name: Cypress run
        uses: cypress-io/github-action@v2
        with:
          working-directory: frontend
          start: npm run serve
          wait-on: 'http://localhost:8080'  

Moreover, my frontend/cypress.json configuration file remains unpopulated, while the frontend/cypress/tsconfig.json within the cypress directory contains the following values:

{
    "include": [
        "./integration/**/*",
        "./support/**/*"
    ],
    "compilerOptions": {
        "isolatedModules": false,
        "target": "es5",
        "lib": [
            "es5",
            "dom"
        ],
        "types": [
            "cypress"
        ]
    }
}

Furthermore, the

frontend/cypress/plugins/tsconfig.json
file is housed within the Plugins folder and incorporates the following configurations:

{
    "include": [
        "./**/*"
    ],
    "compilerOptions": {
        "module": "CommonJS",
        "preserveValueImports": false,
        "types": [
            "node",
            "cypress/types/cypress"
        ]
    }
}

I have essentially mirrored these settings from npm init vue@latest with typescript and cypress. Despite this, I am encountering an issue. What could be the root cause?

Answer №1

I made a mistake by not including typescript in my dependencies:

npm install typescript --save-dev

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Address properties that are undefined before they cause an error

Is there a smart way to manage undefined properties and/or identifiers on an object before they result in failure/returning undefined? Can we intercept access to a non-defined property and address it without resorting to try/catch blocks? var myObj = { ...

Navigating through asynchronous functions without the use of promises

After delving into web-app development using angularJS with its promise library, I find myself facing a new project that lacks such a feature. How can I tackle this challenge without importing an external promise library? To simplify the situation, I need ...

Button for Toggling Audio Play and Pause

Is it possible to create an SVG image that changes color slightly when hovered over, and when clicked toggles to another SVG image that can be switched back to the original by clicking again with the same hover effect? Additionally, when clicked, it should ...

Ways to access the chosen value from Ionic's popover modal

I have been working on a simple Ionic 4 Angular app and I am using an Ionic popover modal. The code below shows how I open the popover modal in my application: //home.page.ts async openModal(ev: Event) { const modal = await this.popoverController.create({ ...

Sending data from JavaScript to PHP using the POST method

I recently learned that using ajax for data passing doesn't require a form or hidden value. I'm hoping to find an example to better understand how it works. index.js: function collectData(r) { // identifies the row index var i = r.pare ...

What could be causing the "Cannot POST /api/" error to occur when attempting to submit a form?

Having issues with my basic website and struggling to find a solution. As a complete beginner in this field, I am stuck and need some guidance. Accessing http://localhost:3000/class/create works perfectly fine when running the server. However, trying to a ...

What causes an "Internal Server Error" when attempting to use data for a database request with AJAX GET/POST in Laravel?

There's a unique issue that I'm struggling to resolve... Every time I drag and drop an event into the calendar, an Ajax Post Request is sent to my controller. The controller then inserts some data into the database with the event name received v ...

Steps to store a string with all characters in a JavaScript variable

I am faced with a situation where I need to pass variables that are considered Javascript objects, in a format similar to the following: var pageVars= [ { origin:'page', property:'name', value:'whatever' }, { origin:& ...

Can you provide instructions on how to use JavaScript to click and hold a button for a specific duration?

Is it possible to use jQuery to create a button that, when guest button number 1 is clicked, will automatically click and hold down button number 2 for about 3 seconds? I have tried using the mousedown() and click(), but they only register a click, not a ...

The attribute 'prop' is not found on the type 'IntrinsicAttributes & TableProp'.ts(2322)

Encountering an error while trying to pass a prop to a React component for the first time. Despite looking at other posts for solutions, I have been unable to resolve it so far. Here is a snippet of my code: type TableProp = {}; function Table(prop: Tabl ...

Create circles with a variety of different colors on the canvas

I need assistance with creating an animation where circles move from right to left on a canvas. The colors of the circles are randomly selected using a function. Currently, I have a fiddle where a single circle moves from right to left, changing color ever ...

Tips for using res.json as a callback function

When using a function with a callback parameter, I found that this method works perfectly fine: DB.last(user,(data) => res.json(data)); However, when attempting to refactor it for better readability as shown below: DB.last(user,res.json); The structu ...

Please convert the code to async/await format and modify the output structure as specified

const getWorkoutPlan = async (plan) => { let workoutPlan = {}; for (let day in plan) { workoutPlan[day] = await Promise.all( Object.keys(plan[day]).map(async (muscle) => { const query = format("select * from %I where id in (%L) ...

Iterating through a nested array in order to dynamically generate elements using JavaScript/jQuery

Seeking assistance with a specific issue I am facing. Despite extensive research on this platform, I have not found a solution to my problem. Recently, I successfully used jQuery each to loop over objects. However, I am currently struggling to iterate thro ...

Best approach for integrating a Three.js project into a Ruby on Rails application?

Struggling to integrate a Three.js project into the Ruby on Rails framework I can't help but feel like there must be a simpler way to accomplish this task compared to my current methods Initially, I searched for a guide or tutorial on how to transfe ...

Utilize CSS in your HTML using Express framework

I am attempting to link a css stylesheet to my basic html webpage. I am utilizing parse.com hosting for dynamic webpages that utilize express. There are numerous responses to this question, but none of them have proven successful in my case. I am trying ...

Creating an Efficient Lazy Loading HTML Page with jQuery

I've been looking to create a page that loads content only as the user scrolls to that specific section, similar to the way Pinterest website functions. Does anyone have suggestions on how to design and implement this feature, or know of any plugins ...

Is it possible for an HTML number input's arrows to change in increments that are different from its designated step attribute?

Within my design, I have implemented an <input type="number" step="1"> element for selecting font size. However, in the context of working on a large canvas, adjusting the number by 1 is hardly noticeable. It would greatly enhance ...

Becoming an expert at managing and solving dependency conflicts

I am facing an issue while setting up a project from my work computer to my home computer due to fixed dependency versions. Here are the dependencies causing the problem: "dependencies": { "@nestjs-modules/mailer": "2.0.2&qu ...

Is there a standard event triggered upon the closing of a browser tab or window?

Does React have a built-in event that is triggered when a browser tab or window is closed? If it does, does it have support across different browsers? ...