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

Cannot set property 'at' of undefined #384

Closed
iffy opened this issue Jun 29, 2017 · 1 comment
Closed

Cannot set property 'at' of undefined #384

iffy opened this issue Jun 29, 2017 · 1 comment

Comments

@iffy
Copy link

iffy commented Jun 29, 2017

For this JS file (which is generated from TypeScript) I'm seeing the error below:

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

Object.defineProperty(exports, "__esModule", { value: true });
const tap = require("tap");
tap.test('foo', (t) => __awaiter(this, void 0, void 0, function* () {
    yield t.rejects(() => {
        return new Promise((resolve, reject) => {
            reject('foo');
        });
    });
}));

Here's the error:

$ tap test.js
test.js ............................................... 0/2
  foo
  not ok Cannot set property 'at' of undefined
    stack: |
      Object.<anonymous> (test.js:14:13)
      Generator.next (<anonymous>)
      test.js:7:71
      __awaiter (test.js:3:12)
      Test.tap.test (test.js:13:24)
    type: TypeError
    test: foo
  
  not ok undefined
    error: foo
    stack: |
      process.emit (node_modules/source-map-support/source-map-support.js:430:21)
      processEmit [as emit] (node_modules/signal-exit/index.js:155:32)

total ................................................. 0/2
  

  0 passing (395.964ms)
  2 failing

It's generated from this TypeScript file (if that matters):

import * as tap from 'tap';

tap.test('foo', async t => {
  await t.rejects(() => {
    return new Promise((resolve, reject) => {
      reject('foo');
    })
  })
})

Versions:

$ tap --version
10.7.0
$ node --version
v7.4.0

Is this a bug in tap or a bug in TypeScript's await/async-to-generators code?

@ghost
Copy link

ghost commented Aug 12, 2017

I have the same for a simple t.rejects(prom, {}, 'a'); in a test function, that makes rejects unusable.

@isaacs isaacs closed this as completed in 52d5983 Aug 12, 2017
iarna added a commit to npm/npm that referenced this issue Aug 18, 2017
made t.rejects handle getting expected error but not options

Credit: @isaacs
Fixes: tapjs/tapjs#384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant