wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
759 stars 45 forks source link

Promise .finally is not a function #2266

Closed MisterQH closed 4 years ago

MisterQH commented 4 years ago

Promise .finally does not seem to work with core v1.0.784

const promise = new Promise((resolve, reject) => resolve(1));
promise.finally(console.log)

==> promise.finally is not a function

smcenlly commented 4 years ago

This seems to be working for us. Could you please try this sample repo that we created?

Is it possible that you're using a promise library, or a version of node.js earlier than 10.x?


We will need you to provide us with your Wallaby Diagnostics report in order to investigate further. Our diagnostics report is a simple JSON text report that contains some basic information about your Wallaby config and project that is required to start troubleshooting most of Wallaby issues.

To share the report:

MisterQH commented 4 years ago

Hello, the sample repo you created is working for me as well. We are using node.js v8.11.3 with babel.

Here is the Diagnosis report:

{ editorVersion: '1.40.0',
  pluginVersion: '1.0.156',
  editorType: 'VSCode',
  osVersion: 'darwin 18.7.0',
  nodeVersion: 'v8.11.3',
  coreVersion: '1.0.784',
  config: 
   { name: 'e-Potek admin tests - Client',
     testFramework: 
      { version: 'mocha@2.1.0',
        configurator: 'mocha@2.1.0',
        reporter: 'mocha@2.1.0',
        starter: 'mocha@2.1.0' },
     files: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
     tests: [ [Object], [Object] ],
     compilers: 
      { '**/*.js?(x)': [Function],
        '**/*.?(lit)coffee?(.md)': [Function] },
     env: 
      { type: 'node',
        params: {},
        runner: '/usr/local/bin/node',
        viewportSize: [Object],
        options: [Object],
        bundle: true },
     diagnostics: {},
     filesWithNoCoverageCalculated: [],
     runAllTestsInAffectedTestFile: false,
     preprocessors: {},
     maxConsoleMessagesPerTest: 100,
     autoConsoleLog: true,
     delays: { run: 0, edit: 100, update: 0 },
     workers: { initial: 0, regular: 0, recycle: false },
     teardown: undefined,
     hints: 
      { ignoreCoverage: '__REGEXP /ignore coverage|istanbul ignore/',
        ignoreCoverageForFile: '__REGEXP /ignore file coverage/',
        commentAutoLog: '?',
        testFileSelection: [Object] },
     automaticTestFileSelection: true,
     runSelectedTestsOnly: false,
     extensions: {},
     reportUnhandledPromises: true,
     slowTestThreshold: 75,
     lowCoverageThreshold: 80,
     loose: undefined,
     configCode: 'const setWallabyConfig = require(\'./imports/core/utils/testHelpers/wallaby/wallabyDefaults\');\n\nmodule.exports = setWallabyConfig(\'e-Potek admin tests - Client\');\n' },
  packageJSON: 
   { dependencies: 
      { '@babel/runtime': '^7.6.3',
        '@fortawesome/fontawesome-svg-core': '^1.2.25',
        '@fortawesome/free-solid-svg-icons': '^5.11.2',
        '@fortawesome/pro-light-svg-icons': '^5.11.2',
        '@fortawesome/react-fontawesome': '^0.1.7',
        '@material-ui/core': '^4.5.2',
        '@material-ui/icons': '^4.5.1',
        'analytics-node': '^3.3.0',
        antd: '^3.25.0',
        archiver: '^3.1.1',
        'aws-sdk': '^2.563.0',
        'babel-polyfill': '^6.26.0',
        base64topdf: '^1.1.8',
        bcrypt: '^3.0.6',
        'body-parser': '^1.19.0',
        btoa: '^1.2.1',
        cheerio: '^1.0.0-rc.2',
        classnames: '^2.2.6',
        'connect-route': '^0.1.5',
        'core-js': '^3.3.6',
        faker: '^4.1.0',
        'file-saver': '^2.0.2',
        googleapis: '^44.0.0',
        'highcharts-export-data': '^0.1.7',
        'highcharts-exporting': '^0.1.7',
        'highcharts-more': '^0.1.7',
        'i18n-iso-countries': '^4.3.1',
        indexof: '0.0.1',
        'intl-messageformat': '^7.5.0',
        'intl-relativeformat': 'https://github.com/Floriferous/intl-relativeformat/tarball/master',
        'js-search': '^1.4.3',
        'json-logic-js': '^1.2.2',
        'libphonenumber-js': '^1.7.26',
        lodash: '^4.17.15',
        'meteor-accounts-t9n': '^2.5.2',
        'meteor-node-stubs': '^0.4.1',
        moment: '^2.24.0',
        'moment-duration-format': '^2.3.2',
        'node-rsa': '^1.0.6',
        'normalize-scss': '^7.0.1',
        'object-hash': '^2.0.0',
        'open-graph-scraper': '^3.6.2',
        'prop-types': '^15.7.2',
        'query-string': '5.1.1',
        react: '^16.11.0',
        'react-autosuggest': '^9.4.3',
        'react-countup': '^4.2.3',
        'react-dates': '^21.3.2',
        'react-dom': '^16.11.0',
        'react-file-viewer': '^1.1.0',
        'react-flip-move': '^3.0.4',
        'react-helmet': '^5.2.1',
        'react-highcharts': '^16.1.0',
        'react-hotkeys': '^2.0.0',
        'react-intl': 'https://github.com/Floriferous/react-intl/tarball/build',
        'react-linkify': '^1.0.0-alpha',
        'react-loadable': '^5.5.0',
        'react-markdown': '^4.2.2',
        'react-places-autocomplete': '^7.2.1',
        'react-redux': '^7.1.1',
        'react-router-dom': '^5.1.2',
        'react-scroll': '^1.7.14',
        'react-scroll-sync': '^0.7.0',
        'react-string-replace': '^0.4.4',
        'react-table': '^7.0.0-alpha.21',
        'react-text-mask': '^5.4.3',
        'react-use': '^13.2.1',
        recompose: '^0.30.0',
        redux: '^4.0.4',
        'redux-logger': '^3.0.6',
        'redux-mock-store': '^1.5.3',
        'redux-thunk': '^2.3.0',
        request: '^2.88.0',
        reselect: '^4.0.0',
        'simpl-schema': '^1.5.6',
        'text-mask-addons': '^3.8.0',
        uniforms: '^2.6.0',
        'uniforms-bridge-simple-schema-2': '^2.6.0',
        'uniforms-material': 'https://github.com/MisterQH/uniforms-material/tarball/master' },
     devDependencies: 
      { '@babel/core': '^7.6.4',
        '@babel/plugin-proposal-class-properties': '^7.5.5',
        '@babel/preset-flow': '^7.0.0',
        'babel-plugin-module-resolver': '^3.2.0',
        'babel-plugin-react-intl': 'https://github.com/Floriferous/babel-plugin-react-intl/tarball/master',
        'babel-preset-meteor': '^7.6.1',
        chai: '^4.2.0',
        'connect-multiparty': '^2.2.0',
        enzyme: '^3.10.0',
        'enzyme-adapter-react-16': '^1.15.1',
        'flow-typed': '^2.6.2',
        jsdom: '^15.2.1',
        'meteor-babel': '7.4.4',
        mocha: '5.2.0',
        'mocha-junit-reporter': '^1.23.1',
        'mocha-multi-reporters': '^1.1.7',
        nightmare: '^3.0.2',
        'react-test-renderer': '^16.11.0',
        sinon: '^7.5.0' } },
  fs: { numberOfFiles: 2064 },
  debug: 
   [ '2019-11-12T07:41:50.191Z project Wallaby Node version: v8.11.3\n',
     '2019-11-12T07:41:50.191Z project Wallaby config: <homeDir>/Documents/dev/epotek/microservices/admin/wallaby-admin.js\n',
     '2019-11-12T07:41:51.670Z project File cache: <homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.156/projects/035013323ea334bd\n',
     '2019-11-12T07:41:51.676Z uiService Listening port 51235\n',
     '2019-11-12T07:41:51.821Z workers Parallelism for initial run: 10, for regular run: 5\n',
     '2019-11-12T07:41:51.821Z workers Starting run worker instance #0\n',
     '2019-11-12T07:41:51.822Z workers Starting run worker instance #1\n',
     '2019-11-12T07:41:51.822Z workers Starting run worker instance #2\n',
     '2019-11-12T07:41:51.822Z workers Starting run worker instance #3\n',
     '2019-11-12T07:41:51.822Z workers Starting run worker instance #4\n',
     '2019-11-12T07:41:51.822Z workers Starting run worker instance #5\n',
     '2019-11-12T07:41:51.822Z workers Starting run worker instance #6\n',
     '2019-11-12T07:41:51.822Z workers Starting run worker instance #7\n',
     '2019-11-12T07:41:51.822Z workers Starting run worker instance #8\n',
     '2019-11-12T07:41:51.822Z workers Starting run worker instance #9\n',
     '2019-11-12T07:41:51.877Z workers Web server is listening at 52359\n',
     '2019-11-12T07:41:52.238Z uiService UI client connected\n',
     '2019-11-12T07:41:52.238Z uiService Outgoing message ui:handshake\n',
     '2019-11-12T07:41:52.289Z project File cache requires some updates, waiting required files from IDE\n',
     '2019-11-12T07:41:52.299Z workers Started run worker instance (delayed) #0\n',
     '2019-11-12T07:41:52.299Z workers Started run worker instance (delayed) #1\n',
     '2019-11-12T07:41:52.300Z extended-core New document or complex document change\n',
     '2019-11-12T07:41:52.301Z uiService Outgoing message ui:files\n',
     '2019-11-12T07:41:52.301Z uiService Outgoing message ui:busy\n',
     '2019-11-12T07:41:52.302Z workers Started run worker instance (delayed) #2\n',
     '2019-11-12T07:41:52.302Z workers Started run worker instance (delayed) #5\n',
     '2019-11-12T07:41:52.303Z workers Started run worker instance (delayed) #4\n',
     '2019-11-12T07:41:52.303Z uiService Incoming message ui:start\n',
     '2019-11-12T07:41:52.303Z uiService Outgoing message ui:summary\n',
     '2019-11-12T07:41:52.319Z uiService Outgoing message ui:files\n',
     '2019-11-12T07:41:52.320Z workers Started run worker instance (delayed) #3\n',
     '2019-11-12T07:41:52.320Z workers Started run worker instance (delayed) #6\n',
     '2019-11-12T07:41:52.411Z workers Started run worker instance (delayed) #9\n',
     '2019-11-12T07:41:52.412Z workers Started run worker instance (delayed) #8\n',
     '2019-11-12T07:41:52.412Z workers Started run worker instance (delayed) #7\n',
     '2019-11-12T07:41:52.539Z uiService Incoming message ui:closedInEditor\n',
     '2019-11-12T07:41:52.540Z uiService Incoming message ui:codeRequested\n',
     '2019-11-12T07:41:52.541Z uiService Outgoing message ui:code\n',
     '2019-11-12T07:41:52.543Z uiService Incoming message ui:openedInEditor\n',
     '2019-11-12T07:41:53.436Z project Stopping process pool\n',
     '2019-11-12T07:41:53.437Z uiService Outgoing message ui:busy\n',
     '2019-11-12T07:41:53.438Z project Running postprocessor\n',
     '2019-11-12T07:41:53.582Z postprocessor New TypeScript language service is required\n',
     '2019-11-12T07:41:53.601Z postprocessor TypeScript postprocessor will be removed because in 2064 project files none were found by patterns: **/*.ts?(x)\n',
     '2019-11-12T07:41:53.606Z project Postprocessor execution finished\n',
     '2019-11-12T07:41:53.606Z project Postprocessor is removed as requested by itself\n',
     '2019-11-12T07:41:53.606Z project Test run started; run priority: 3\n',
     '2019-11-12T07:41:53.607Z project Running all tests\n',
     '2019-11-12T07:41:53.644Z workers Starting test run, priority: 3\n',
     '2019-11-12T07:41:53.644Z nodeRunner Starting sandbox [worker #0, session #y6k6s]\n',
     '2019-11-12T07:41:53.644Z nodeRunner Preparing sandbox [worker #0, session #y6k6s]\n',
     '2019-11-12T07:41:53.644Z nodeRunner Prepared sandbox [worker #0, session #y6k6s]\n',
     '2019-11-12T07:41:53.644Z workers [worker #0, session #y6k6s] Running tests in sandbox\n',
     '2019-11-12T07:41:54.630Z workers [y6k6s] Loaded 7 test(s)\n',
     '2019-11-12T07:41:54.772Z workers [y6k6s] Test executed: renders the select field\n',
     '2019-11-12T07:41:54.984Z workers [y6k6s] Run 1 test(s), skipped 0 test(s)\n',
     '2019-11-12T07:41:54.990Z workers [y6k6s] Sandbox is responsive, closing it\n',
     '2019-11-12T07:41:54.991Z project Test run finished\n',
     '2019-11-12T07:41:54.991Z project Processed console.log entries\n',
     '2019-11-12T07:41:54.991Z project Processed loading sequences\n',
     '2019-11-12T07:41:54.992Z project Processed executed tests\n',
     '2019-11-12T07:41:55.127Z project Processed code coverage\n',
     '2019-11-12T07:41:55.537Z project Test run result processed and sent to IDE\n',
     '2019-11-12T07:41:55.537Z uiService Outgoing message ui:summary\n',
     '2019-11-12T07:41:55.553Z uiService Outgoing message ui:coverageChanged\n',
     '2019-11-12T07:41:55.554Z uiService Outgoing message ui:files\n',
     '2019-11-12T07:41:55.571Z uiService Incoming message ui:codeRequested\n',
     '2019-11-12T07:41:55.573Z uiService Outgoing message ui:code\n' ] }
smcenlly commented 4 years ago

Could you also please provide us with your babel config?

MisterQH commented 4 years ago

Yes sure, here's how we set our wallaby config, with the babel config:

const merge = require('lodash/merge');
// Use old-school javascript in this file to make it work nicely

function setWallabyConfig(name, overrides = {}) {
  return function setupWallaby(wallaby) {
    return merge(
      {},
      {
        name,
        // debug: true, // Use this if things go wrong
        testFramework: 'mocha',
        files: [
          // load all files in imports
          'imports/**/**.js*',
          // Don't load node_modules twice
          '!imports/core/node_modules/**',
          // Don't import unnecessary folders
          '!imports/core/assets/**',
          // Don't load tests here, but in the next variable
          '!imports/**/*.spec.js*',
          // Load language files for some tests
          'lang/*.json',
          // // Don't load css files
          { pattern: 'node_modules/**/*.css', ignore: true },
        ],
        tests: ['imports/**/*.spec.js*', '!imports/core/node_modules/**'],
        compilers: {
          '**/*.js?(x)': wallaby.compilers.babel({
            presets: ['meteor', '@babel/preset-react', '@babel/preset-flow'],
            plugins: [
              '@babel/plugin-transform-modules-commonjs',
              '@babel/plugin-proposal-class-properties',
              'meteor-babel/plugins/dynamic-import',
              [
                'module-resolver',
                {
                  root: ['.'],
                  alias: {
                    core: './imports/core',
                    meteor: './imports/core/utils/testHelpers/meteorStubs',
                  },
                },
              ],
            ],
          }),
        },
        env: { type: 'node' },
        setup() {
          global.IS_WALLABY = true;
          global.fetch = require('node-fetch');

          // Configure jsdom for react mount tests
          const jsdom = require('jsdom');

          const { JSDOM } = jsdom;
          const { document } = new JSDOM(
            '<!doctype html><html><body></body></html>',
          ).window;
          global.document = document;
          global.window = document.defaultView;
          global.navigator = { userAgent: 'node.js', platform: 'MacIntel' };

          // Do this for react-use, which uses the global variable "history"
          // Follow this issue: https://github.com/streamich/react-use/issues/73
          global.history = {};

          require('uniforms-bridge-simple-schema-2');
          const SimpleSchema = require('simpl-schema').default;
          SimpleSchema.extendOptions([
            'index',
            'unique',
            'denyInsert',
            'denyUpdate',
            'uniforms',
            'condition',
            'customAllowedValues',
            'customAutoValue',
          ]);
        },
      },
      overrides,
    );
  };
}

module.exports = setWallabyConfig;
smcenlly commented 4 years ago

Thanks for sending through the diagnostics report and node version details.

Promise.finally was not added until nodejs v10.0.0 which is why this is not working for you. You will either need to upgrade your nodejs version to 10.x+ or else update your babel configuration to include a polyfill for babel that adds Promise.finally.

We tried to mock your project dependencies and added Promise.finally support by changing the babel presets in your wallaby configuration to:

...
  presets: [
    'meteor', 
    '@babel/preset-react', 
    '@babel/preset-flow', 
+   ["@babel/preset-env", { useBuiltIns: 'usage', corejs: 3 } ]
  ],
...

If you don't already have @babel/preset-env installed, you may need to add it, @babel/polyfill, and core-js as dependencies. We recommend referring to the babel polyfill docs for how to correctly apply this for your project.