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

@swc/core threw an error when attempting to validate swc compiler options. #3915

Closed
reallymello opened this issue Sep 21, 2023 · 3 comments
Closed
Labels

Comments

@reallymello
Copy link
Contributor

reallymello commented Sep 21, 2023

Description of the bug/issue

When I use npm init nightwatch@latest to setup a scaffolded Nightwatch 3 project I expect to be able to run the example tests when I run npx nightwatch, but instead I receive error

┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│                                                                                                                                                                                                                                                                                      │

                                                                       ││   @swc/core threw an error when attempting to va                                                                                                                                                             │lidate swc compiler options.                                                                                                                                                                                                                                                           │
                                                                                                           ││   You may be                                                                                                                                                             │ using an old version of swc which does not support the options used by ts-node.                                                                                                                                                                                                       │
                                                                                                                          ":false,"jsc":{"parser":{"syntax":"typescript","tsx":false,"dynamicImport":true,"importAssertions":true},"target":"es2022","transform":{"legacyDecorator":   │
                     ││   Try upgrading to the latest version of swc.                                                     ns":true}}}                                                                                                                                                  │

                                                         ││   Error message from swc:                                                                                                                                                                                                  │
                                                                                                                          s`, `cacheRoot`, `disableBuiltinTransformsForInternalTesting` at line 1 column 395                                                                           │
                                                                                             ││   Failed to deserialize bu                                                                                                                                                             │ffer as swc::config::Options                                                                                                                                                                                                                                                           │
                                                                                                                          ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Steps to reproduce

  1. Run npm init nightwatch@latest
  2. Select end to end testing and TypeScript as your setup settings.
  3. Delete the example tests except google.ts
  4. Run npx nightwatch

Error will appear in console

Sample test

import { NightwatchAPI, NightwatchTests } from 'nightwatch';

const home: NightwatchTests = {
  'Google title test': () => {
    browser.url('https://google.com/ncr').assert.titleEquals('Google');
  },

  'Google search test': () => {
    browser
      .setValue('textarea[name=q]', 'nightwatchjs')
      .perform(function (this: NightwatchAPI) {
        const actions = this.actions({ async: true });

        return actions.keyDown(this.Keys['ENTER']).keyUp(this.Keys['ENTER']);
      })
      .waitForElementVisible('#main')
      .assert.textContains('#main', 'Nightwatch.js');
  },
};

export default home;

Command to run

npx nightwatch

Verbose Output

PS C:\Users\Mr\Desktop\nwAsyncExample> npx nightwatch --verbose
 
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│                                                                                                                                                                                                                                                                                      ││   @swc/core threw an error when attempting to validate swc compiler options.                                                                                                                                                                                                         ││   You may be using an old version of swc which does not support the options used by ts-node.                                                                                                                                                                                         ││   Try upgrading to the latest version of swc.                                                                                                                                                                                                                                        ││   Error message from swc:                                                                                                                                                                                                                                                            ││   Failed to deserialize buffer as swc::config::Options                                                                                                                                                                                                                               ││   JSON: {"sourceMaps":true,"module":{"noInterop":false,"type":"commonjs","strictMode":true,"ignoreDynamic":false},"swcrc":false,"jsc":{"parser":{"syntax":"typescript","tsx":false,"dynamicImport":true,"importAssertions":true},"target":"es2022","transform":{"legacyDecorator":   ││   true,"react":{"throwIfNamespace":false,"useBuiltins":false}},"keepClassNames":true,"experimental":{"keepImportAssertions":true}}}                                                                                                                                                  ││                                                                                                                                                                                                                                                                                      ││   Caused by:                                                                                                                                                                                                                                                                         ││   unknown field `keepImportAssertions`, expected one of `plugins`, `keepImportAttributes`, `emitAssertForImportAttributes`, `cacheRoot`, `disableBuiltinTransformsForInternalTesting` at line 1 column 395                                                                           ││                                                                                                                                                                                                                                                                                      ││                                                                                                                                                                                                                                                                                      │└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Nightwatch Configuration

// Refer to the online docs for more details:
// https://nightwatchjs.org/gettingstarted/configuration/
//

//  _   _  _         _      _                     _          _
// | \ | |(_)       | |    | |                   | |        | |
// |  \| | _   __ _ | |__  | |_ __      __  __ _ | |_   ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\  || || (_| || | | || |_  \ V  V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__|  \_/\_/   \__,_| \__| \___||_| |_|
//             __/ |
//            |___/

module.exports = {
  // An array of folders (excluding subfolders) where your tests are located;
  // if this is not specified, the test source must be passed as the second argument to the test runner.
  src_folders: ['test','nightwatch'],

  // See https://nightwatchjs.org/guide/concepts/page-object-model.html
  page_objects_path: [],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
  custom_commands_path: [],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
  custom_assertions_path: [],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
  plugins: [],
  
  // See https://nightwatchjs.org/guide/concepts/test-globals.html
  globals_path: '',
  
  webdriver: {},

  test_workers: {
    enabled: true
  },

  test_settings: {
    default: {
      disable_error_log: false,
      launch_url: 'file:///C:/Users/Mr/Desktop/nwAsyncExample/example.html',

      screenshots: {
        enabled: false,
        path: 'screens',
        on_failure: true
      },

      desiredCapabilities: {
        browserName: 'chrome'
      },
      
      webdriver: {
        start_process: true,
        server_path: ''
      },
      
    },
    
    chrome: {
      desiredCapabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
          // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
          //
          // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
          w3c: true,
          args: [
            //'--no-sandbox',
            //'--ignore-certificate-errors',
            //'--allow-insecure-localhost',
            //'--headless'
          ]
        }
      },

      webdriver: {
        start_process: true,
        server_path: '',
        cli_args: [
          // --verbose
        ]
      }
    },
    
  },
  
};

Nightwatch.js Version

3.1.3

Node Version

18.16.0

Browser

Chrome 117

Operating System

Windows 10

Additional Information

image

@reallymello
Copy link
Contributor Author

Workaround is to change the tsconfig.json from

image

to

image

@beatfactor beatfactor added the p0 label Sep 22, 2023
@beatfactor
Copy link
Member

Thanks for reporting this. It appears to be an issue with ts-node, we'll have to disable swc for now.

@beatfactor
Copy link
Member

Fixed.

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

No branches or pull requests

2 participants