Giter VIP home page Giter VIP logo

Comments (12)

samselikoff avatar samselikoff commented on July 18, 2024 4

Right, thanks man. If we do pull the trigger on this, it will be quite easy to undo if it causes any issues.

Thanks a lot Stef!

from pretender.

stefanpenner avatar stefanpenner commented on July 18, 2024 1

@samselikoff I don't have strong feelings either way, but am happy to support your calls here. They seem perfectly reasonable.

from pretender.

samselikoff avatar samselikoff commented on July 18, 2024 1

@GriffinSauce not sure but thanks for the suggestion, after Thomas' latest commit I have it working + can now get to work on this!

from pretender.

stefanpenner avatar stefanpenner commented on July 18, 2024

It's likely ok to bundle whatwg-fetch as part of a dev time build step and presenting them as one bundle to consumers.

But I am not super enthusiastic about actually copying whatwg-fetch code & tests into this repo. It seems like keeping it simple to upgrade if we want to is important, and having the code copied seems like a hazard.

I can be convinced, these are only my first thoughts.

from pretender.

samselikoff avatar samselikoff commented on July 18, 2024

Ya. I think we would just copy this file: https://github.com/github/fetch/blob/master/fetch.js. So 500 lines of code. The last release of whatwg-fetch was 1 year ago.

If there were updates to whatwg-fetch, it's true we wouldn't know about them (at least right away). But again we should compare that to the current situation, in which we're relying on internals, which means whatwg-fetch could push out a patch version that refactors away from their reliance on XMLHTTPRequest and that would break Pretender. Is that likely to happen? Not sure. There are other newer polyfills of fetch that don't use XMLHTTPRequest, so maybe. In any case I do think it's strange for us to be relying on the internals of an external dependency.

I don't think we'd need whatwg-fetch's tests, I think our tests cover Pretender's public API and that's sufficient.

An alternative would be to update Pretender's code to "properly" support intercepting fetch, i.e. actually proxy the fetch APIs to Pretender's. But that would effectively involve bringing in a fetch implementation, and pointing it to our APIs, which effectively would boil down to something that looks a lot like bringing in whatwg-fetch and using it as the boundary layer to redirect fetch APIs to our own.

So ultimately I think vendoring whatwg-fetch is a lot like adding a "proper" fetch adapter to Pretender.

from pretender.

xg-wang avatar xg-wang commented on July 18, 2024

I haven't digged into how next.js resolves import * from 'whatwg-fetch', I would +1 to Stef's suggestion to do this at build time and make sure the scoped xhr is used.
Not sure about proxying fetch. It seems like building another polyfill, which whatwg-fetch already did the work.

from pretender.

samselikoff avatar samselikoff commented on July 18, 2024

Ohh I see – I don't think I fully understood.

Are you all saying we could keep whatwg-fetch as a dependency here in package.json, but for Pretender's publishing step, go ahead and pull it in + make it into an internal dependency? So there's no chance of it being overridden, hoisted or something else?

from pretender.

samselikoff avatar samselikoff commented on July 18, 2024

Another point @ryanto raised is that, currently Pretender is not importable in node, due to whatwg-fetch assuming a browser-like environment. This is another headache for us because even though Mirage doesn't yet work in Node, it needs to be importable so it doesn't break setups like Gatsby that expect isomorphic app code.

This led us needing to create some polyfills and use them like this: https://github.com/miragejs/miragejs/blob/23fb9fe3278af513e1a95c8a09c669e4a47fcd45/lib/server.js#L3. This ensure our polyfill code runs before Pretender is imported (and thus before whatwg-fetch is imported). The code essentially just ensures self is defined, which is all whatwg-fetch needs to be importable (again, not functional, which is not what we're interested at this time).

So, if we were to copy the 500-line whatwg-fetch file directly into Pretender, we could also solve this issue and make sure Pretender doesn't break node apps if it's in the import path, by simply wrapping the code in an if global.self === 'undefined') block.

I understand the purist argument about leaving whatwg-fetch in package.json, but Pretender's build file + logic is already pretty messy + hard to read/maintain, and whatwg-fetch's last release was over a year ago, so I think pragmatically the simplest way to solve this problem today is to just create a new file in Pretender, copy the 500 lines, make a comment at the top of the file and be done with it. And I also think the risk is very low.

Just some more of my thoughts!

from pretender.

GriffinSauce avatar GriffinSauce commented on July 18, 2024

Really appreciate the effort here guys! 🙌

from pretender.

samselikoff avatar samselikoff commented on July 18, 2024

Any trick to getting Pretender's test suite running locally? I started work on this but master is failing on my machine for a bunch of reasons...

yarn test
➜  pretender git:(vendor-whatwg-fetch) ✗ yarn test
yarn run v1.21.1
$ bower install
$ npm run lint && npm run eslint && npm run tests-only
npm WARN lifecycle The node binary used for scripts is /var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/yarn--15824094412
85-0.3022276787043625/node but npm is using /Users/samselikoff/.nodenv/versions/12.16.0/bin/node itself. Use the `--scrip
ts-prepend-node-path` option to include the path for the node binary npm was executed with.

> [email protected] lint /Users/samselikoff/Projects/oss/pretender
> jshint test

npm WARN lifecycle The node binary used for scripts is /var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/yarn--15824094412
85-0.3022276787043625/node but npm is using /Users/samselikoff/.nodenv/versions/12.16.0/bin/node itself. Use the `--scrip
ts-prepend-node-path` option to include the path for the node binary npm was executed with.

> [email protected] eslint /Users/samselikoff/Projects/oss/pretender
> eslint src/**/*.ts test

npm WARN lifecycle The node binary used for scripts is /var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/yarn--15824094412
85-0.3022276787043625/node but npm is using /Users/samselikoff/.nodenv/versions/12.16.0/bin/node itself. Use the `--scrip
ts-prepend-node-path` option to include the path for the node binary npm was executed with.

> [email protected] tests-only /Users/samselikoff/Projects/oss/pretender
> karma start --single-run

22 02 2020 17:10:44.445:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
22 02 2020 17:10:44.447:INFO [launcher]: Launching browsers Chrome, PhantomJS with unlimited concurrency
22 02 2020 17:10:44.451:INFO [launcher]: Starting browser Chrome
22 02 2020 17:10:44.457:INFO [launcher]: Starting browser PhantomJS
22 02 2020 17:10:45.453:INFO [Chrome 80.0.3987 (Mac OS X 10.15.3)]: Connected on socket VCT2Nx9PjwzfYoIfAAAA with id 2170
2188
22 02 2020 17:10:45.557:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket oRy3yOMfjOk2sBphAAAB with id 2755994
5
..........................................
Chrome 80.0.3987 (Mac OS X 10.15.3) pretender invoking async requests with `onprogress` upload events in the upload  trig
ger a progress event each 50ms FAILED
        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:423:16)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:423:16)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:423:16)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:423:16)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:423:16)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177

Chrome 80.0.3987 (Mac OS X 10.15.3) pretender invoking `onprogress` upload events don't keep firing once the request has 
ended FAILED
        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 210
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:460:14)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177
            at callTimer (node_modules/sinon/pkg/sinon.js:7096:20)

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 210
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:460:14)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177
            at callTimer (node_modules/sinon/pkg/sinon.js:7096:20)

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 210
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:460:14)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177
            at callTimer (node_modules/sinon/pkg/sinon.js:7096:20)

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 210
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:460:14)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177
            at callTimer (node_modules/sinon/pkg/sinon.js:7096:20)

Chrome 80.0.3987 (Mac OS X 10.15.3) pretender invoking no progress upload events are fired after the request is aborted FAILED
        ProgressEvent has total of requestBody byte size
        Expected: 8
        Actual: 210
            at EventedObject.xhr.upload.onprogress (test/calling_test.js:495:14)
            at EventedObject.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at EventedObject.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at EventedObject._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16177
            at callTimer (node_modules/sinon/pkg/sinon.js:7096:20)

PhantomJS 2.1.1 (Mac OS X 0.0.0) pretender invoking async requests with `onprogress` upload events in the upload  trigger a progress event each 50ms FAILED
        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
        onprogress@test/calling_test.js:423:21
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
        onprogress@test/calling_test.js:423:21
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
        onprogress@test/calling_test.js:423:21
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
        onprogress@test/calling_test.js:423:21
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 300
        onprogress@test/calling_test.js:423:21
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046

PhantomJS 2.1.1 (Mac OS X 0.0.0) pretender invoking `onprogress` upload events don't keep firing once the request has ended FAILED
        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 210
        onprogress@test/calling_test.js:460:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046
        callTimer@node_modules/sinon/pkg/sinon.js:7096:25
        tick@node_modules/sinon/pkg/sinon.js:7319:30
        test/calling_test.js:466:15
        runTest@node_modules/qunit/qunit/qunit.js:3041:34
        run@node_modules/qunit/qunit/qunit.js:3027:13
        node_modules/qunit/qunit/qunit.js:3258:15
        processTaskQueue@node_modules/qunit/qunit/qunit.js:2614:28
        node_modules/qunit/qunit/qunit.js:2618:24
        invokeCallback@node_modules/qunit/qunit/qunit.js:1699:25
        node_modules/qunit/qunit/qunit.js:1467:30
        flush@node_modules/qunit/qunit/qunit.js:1419:15

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 210
        onprogress@test/calling_test.js:460:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046
        callTimer@node_modules/sinon/pkg/sinon.js:7096:25
        tick@node_modules/sinon/pkg/sinon.js:7319:30
        test/calling_test.js:466:15
        runTest@node_modules/qunit/qunit/qunit.js:3041:34
        run@node_modules/qunit/qunit/qunit.js:3027:13
        node_modules/qunit/qunit/qunit.js:3258:15
        processTaskQueue@node_modules/qunit/qunit/qunit.js:2614:28
        node_modules/qunit/qunit/qunit.js:2618:24
        invokeCallback@node_modules/qunit/qunit/qunit.js:1699:25
        node_modules/qunit/qunit/qunit.js:1467:30
        flush@node_modules/qunit/qunit/qunit.js:1419:15

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 210
        onprogress@test/calling_test.js:460:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046
        callTimer@node_modules/sinon/pkg/sinon.js:7096:25
        tick@node_modules/sinon/pkg/sinon.js:7319:30
        test/calling_test.js:466:15
        runTest@node_modules/qunit/qunit/qunit.js:3041:34
        run@node_modules/qunit/qunit/qunit.js:3027:13
        node_modules/qunit/qunit/qunit.js:3258:15
        processTaskQueue@node_modules/qunit/qunit/qunit.js:2614:28
        node_modules/qunit/qunit/qunit.js:2618:24
        invokeCallback@node_modules/qunit/qunit/qunit.js:1699:25
        node_modules/qunit/qunit/qunit.js:1467:30
        flush@node_modules/qunit/qunit/qunit.js:1419:15

        ProgressEvent has total of requestBody byte size
        Expected: 9
        Actual: 210
        onprogress@test/calling_test.js:460:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046
        callTimer@node_modules/sinon/pkg/sinon.js:7096:25
        tick@node_modules/sinon/pkg/sinon.js:7319:30
        test/calling_test.js:466:15
        runTest@node_modules/qunit/qunit/qunit.js:3041:34
        run@node_modules/qunit/qunit/qunit.js:3027:13
        node_modules/qunit/qunit/qunit.js:3258:15
        processTaskQueue@node_modules/qunit/qunit/qunit.js:2614:28
        node_modules/qunit/qunit/qunit.js:2618:24
        invokeCallback@node_modules/qunit/qunit/qunit.js:1699:25
        node_modules/qunit/qunit/qunit.js:1467:30
        flush@node_modules/qunit/qunit/qunit.js:1419:15

PhantomJS 2.1.1 (Mac OS X 0.0.0) pretender invoking no progress upload events are fired after the request is aborted FAILED
        ProgressEvent has total of requestBody byte size
        Expected: 8
        Actual: 210
        onprogress@test/calling_test.js:495:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18046
        callTimer@node_modules/sinon/pkg/sinon.js:7096:25
        tick@node_modules/sinon/pkg/sinon.js:7319:30
        test/calling_test.js:502:15
        runTest@node_modules/qunit/qunit/qunit.js:3041:34
        run@node_modules/qunit/qunit/qunit.js:3027:13
        node_modules/qunit/qunit/qunit.js:3258:15
        processTaskQueue@node_modules/qunit/qunit/qunit.js:2614:28
        node_modules/qunit/qunit/qunit.js:2618:24
        invokeCallback@node_modules/qunit/qunit/qunit.js:1699:25
        node_modules/qunit/qunit/qunit.js:1467:30
        flush@node_modules/qunit/qunit/qunit.js:1419:15

Chrome 80.0.3987 (Mac OS X 10.15.3) pretender invoking async requests with `onprogress` events trigger a progress event each 50ms FAILED
        GET request has no requestBody
        Expected: 0
        Actual: 300
            at FakeRequest.xhr.onprogress (test/calling_test.js:528:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

        Expected: 300
        Actual: 51
            at FakeRequest.xhr.onprogress (test/calling_test.js:529:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

        GET request has no requestBody
        Expected: 0
        Actual: 300
            at FakeRequest.xhr.onprogress (test/calling_test.js:528:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

        Expected: 300
        Actual: 103
            at FakeRequest.xhr.onprogress (test/calling_test.js:529:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

        GET request has no requestBody
        Expected: 0
        Actual: 300
            at FakeRequest.xhr.onprogress (test/calling_test.js:528:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

        Expected: 300
        Actual: 157
            at FakeRequest.xhr.onprogress (test/calling_test.js:529:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

        GET request has no requestBody
        Expected: 0
        Actual: 300
            at FakeRequest.xhr.onprogress (test/calling_test.js:528:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

        Expected: 300
        Actual: 209
            at FakeRequest.xhr.onprogress (test/calling_test.js:529:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

        GET request has no requestBody
        Expected: 0
        Actual: 300
            at FakeRequest.xhr.onprogress (test/calling_test.js:528:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

        Expected: 300
        Actual: 260
            at FakeRequest.xhr.onprogress (test/calling_test.js:529:14)
            at FakeRequest.<anonymous> (node_modules/fake-xml-http-request/fake_xml_http_request.js:137:18)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at FakeRequest._progress (node_modules/fake-xml-http-request/fake_xml_http_request.js:199:12)
            at dist/pretender.js:9:16264

.............22 02 2020 17:10:46.565:WARN [web-server]: 404: /some/path
.
PhantomJS 2.1.1 (Mac OS X 0.0.0) pretender invoking async requests with `onprogress` events trigger a progress event each 50ms FAILED
        GET request has no requestBody
        Expected: 0
        Actual: 300
        onprogress@test/calling_test.js:528:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

        Expected: 300
        Actual: 52
        onprogress@test/calling_test.js:529:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

        GET request has no requestBody
        Expected: 0
        Actual: 300
        onprogress@test/calling_test.js:528:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

        Expected: 300
        Actual: 103
        onprogress@test/calling_test.js:529:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

        GET request has no requestBody
        Expected: 0
        Actual: 300
        onprogress@test/calling_test.js:528:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

        Expected: 300
        Actual: 155
        onprogress@test/calling_test.js:529:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

        GET request has no requestBody
        Expected: 0
        Actual: 300
        onprogress@test/calling_test.js:528:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

        Expected: 300
        Actual: 208
        onprogress@test/calling_test.js:529:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

        GET request has no requestBody
        Expected: 0
        Actual: 300
        onprogress@test/calling_test.js:528:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

        Expected: 300
        Actual: 260
        onprogress@test/calling_test.js:529:19
        node_modules/fake-xml-http-request/fake_xml_http_request.js:137:22
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        _progress@node_modules/fake-xml-http-request/fake_xml_http_request.js:199:25
        dist/pretender.js:9:18133

...22 02 2020 17:10:46.581:WARN [web-server]: 404: /some/path
.............22 02 2020 17:10:46.588:WARN [web-server]: 404: /some/path
..........22 02 2020 17:10:46.600:WARN [web-server]: 404: /some/otherpath
..22 02 2020 17:10:46.606:WARN [web-server]: 404: /some/otherpath
..
Chrome 80.0.3987 (Mac OS X 10.15.3) passthrough requests asynchronous request with pass-through and empty response FAILED
        response for real and fake xhr are both blank strings
        Expected: ""
        Actual: null
            at FakeRequest._onload (test/passthrough_test.js:332:14)
            at FakeRequest.dispatchEvent (node_modules/fake-xml-http-request/fake_xml_http_request.js:181:24)
            at dispatchEvent (dist/pretender.js:9:11588)
            at testXHR.xhr.<computed> [as onload] (dist/pretender.js:9:12162)
            at Object.apply (test/passthrough_test.js:316:15)
            at FakeRequest.send (dist/pretender.js:9:9275)

Chrome 80.0.3987 (Mac OS X 10.15.3) passthrough requests > the `.passthrough()` property allows a passthrough on an unhandledRequest FAILED
        Expected: 404
        Actual: 0
            at Object.error (test/passthrough_test.js:354:18)
            at j (bower_components/jquery-1/index.js:2:27309)
            at Object.fireWith [as rejectWith] (bower_components/jquery-1/index.js:2:28122)
            at x (bower_components/jquery-1/index.js:5:22136)
            at Function.ajax (bower_components/jquery-1/index.js:5:21607)
            at Object.<anonymous> (test/passthrough_test.js:351:9)

.
Chrome 80.0.3987 (Mac OS X 10.15.3) passthrough requests > the `.passthrough()` property returns a native xhr FAILED
        Died on test #1     at Object.<anonymous> (test/passthrough_test.js:360:5)
            at processModule (node_modules/qunit/qunit/qunit.js:1191:16)
            at module$1 (node_modules/qunit/qunit/qunit.js:1216:4)
            at Object.<anonymous> (test/passthrough_test.js:343:3)
            at processModule (node_modules/qunit/qunit/qunit.js:1191:16)
            at module$1 (node_modules/qunit/qunit/qunit.js:1216:4)
            at test/passthrough_test.js:5:1: request.passthrough is not a function
        TypeError: request.passthrough is not a function
            at Pretender.pretender.unhandledRequest (test/passthrough_test.js:385:37)
            at Pretender.handleRequest (dist/pretender.js:9:21831)
            at FakeRequest.send (dist/pretender.js:9:9397)
            at Object.<anonymous> (test/passthrough_test.js:390:11)
            at runTest (node_modules/qunit/qunit/qunit.js:3041:30)
            at Test.run (node_modules/qunit/qunit/qunit.js:3027:6)
            at node_modules/qunit/qunit/qunit.js:3258:12
            at processTaskQueue (node_modules/qunit/qunit/qunit.js:2614:24)
            at node_modules/qunit/qunit/qunit.js:2618:8

22 02 2020 17:10:46.629:WARN [web-server]: 404: /some/path
.22 02 2020 17:10:46.644:WARN [web-server]: 404: /some/path
.................
Chrome 80.0.3987 (Mac OS X 10.15.3): Executed 78 of 78 (7 FAILED) (0.962 secs / 0.921 secs)
.............22 02 2020 17:10:46.671:WARN [web-server]: 404: /some/path
.22 02 2020 17:10:46.685:WARN [web-server]: 404: /some/path
....22 02 2020 17:10:46.701:WARN [web-server]: 404: /some/otherpath
.22 02 2020 17:10:46.708:WARN [web-server]: 404: /some/otherpath
.
PhantomJS 2.1.1 (Mac OS X 0.0.0) passthrough requests asynchronous request with pass-through and empty response FAILED
        response for real and fake xhr are both blank strings
        Expected: ""
        Actual: null
        _onload@test/passthrough_test.js:332:19
        dispatchEvent@node_modules/fake-xml-http-request/fake_xml_http_request.js:181:28
        dispatchEvent@dist/pretender.js:9:30958
        dist/pretender.js:9:31532
        apply@test/passthrough_test.js:316:21
        send@dist/pretender.js:9:19183
        test/passthrough_test.js:340:13
        runTest@node_modules/qunit/qunit/qunit.js:3041:34
        run@node_modules/qunit/qunit/qunit.js:3027:13
        node_modules/qunit/qunit/qunit.js:3258:15
        processTaskQueue@node_modules/qunit/qunit/qunit.js:2614:28
        node_modules/qunit/qunit/qunit.js:2618:24
        invokeCallback@node_modules/qunit/qunit/qunit.js:1699:25
        node_modules/qunit/qunit/qunit.js:1467:30
        flush@node_modules/qunit/qunit/qunit.js:1419:15

PhantomJS 2.1.1 (Mac OS X 0.0.0) passthrough requests > the `.passthrough()` property allows a passthrough on an unhandledRequest FAILED
        Expected: 404
        Actual: 0
        error@test/passthrough_test.js:354:23
        j@bower_components/jquery-1/index.js:2:27578
        fireWith@bower_components/jquery-1/index.js:2:55529
        x@bower_components/jquery-1/index.js:5:41346
        ajax@bower_components/jquery-1/index.js:5:21608
        test/passthrough_test.js:351:13
        runTest@node_modules/qunit/qunit/qunit.js:3041:34
        run@node_modules/qunit/qunit/qunit.js:3027:13
        node_modules/qunit/qunit/qunit.js:3258:15
        processTaskQueue@node_modules/qunit/qunit/qunit.js:2614:28
        node_modules/qunit/qunit/qunit.js:2618:24
        invokeCallback@node_modules/qunit/qunit/qunit.js:1699:25
        node_modules/qunit/qunit/qunit.js:1467:30
        flush@node_modules/qunit/qunit/qunit.js:1419:15

22 02 2020 17:10:46.738:WARN [web-server]: 404: /some/path
PhantomJS 2.1.1 (Mac OS X 0.0.0) passthrough requests > the `.passthrough()` property returns a native xhr FAILED
        Died on test #1 undefined: undefined is not a constructor (evaluating 'request.passthrough()')
        unhandledRequest@test/passthrough_test.js:385:48
        handleRequest@dist/pretender.js:9:23707
        send@dist/pretender.js:9:19313
        test/passthrough_test.js:390:15
        runTest@node_modules/qunit/qunit/qunit.js:3041:34
        run@node_modules/qunit/qunit/qunit.js:3027:13
        node_modules/qunit/qunit/qunit.js:3258:15
        processTaskQueue@node_modules/qunit/qunit/qunit.js:2614:28
        node_modules/qunit/qunit/qunit.js:2618:24
        invokeCallback@node_modules/qunit/qunit/qunit.js:1699:25
        node_modules/qunit/qunit/qunit.js:1467:30
        flush@node_modules/qunit/qunit/qunit.js:1419:15

.................
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 78 of 78 (7 FAILED) (0.982 secs / 0.962 secs)
TOTAL: 14 FAILED, 142 SUCCESS
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] tests-only: `karma start --single-run`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] tests-only script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/samselikoff/.npm/_logs/2020-02-22T22_10_46_916Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

from pretender.

GriffinSauce avatar GriffinSauce commented on July 18, 2024

test does run successfully after running test-ci once, seems like the pretest task is missing in the test command, does that help?

from pretender.

xg-wang avatar xg-wang commented on July 18, 2024

Closed by #296

from pretender.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.