Repository: facebook/react
File: packages/react-dom/src/__tests__/ReactServerRendering-test.js (JavaScript)

Code before:
        'renderToNodeStream is deprecated. Use renderToPipeableStream instead.',
        {withoutStack: true},
      );
      expect(response.read().toString()).toMatch(new RegExp('<img' + '/>'));
    });

    it('should handle errors correctly', () => {
      const FailingElement = React.createElement(() => {
        throw new Error('An Error');
      });
      let response;
      expect(() => {
        response = ReactDOMServer.renderToNodeStream(FailingElement);
      }).toErrorDev(
        'renderToNodeStream is deprecated. Use renderToPipeableStream instead.',
        {withoutStack: true},
      );
      return new Promise(resolve => {
        response.once('error', () => {
          resolve();
        });
        expect(response.read()).toBeNull();
      });
    });
  });

  describe('renderToStaticNodeStream', () => {
    it('should generate simple markup', () => {
      const SuccessfulElement = React.createElement(() => <img />);
      const response =
        ReactDOMServer.renderToStaticNodeStream(SuccessfulElement);
      expect(response.read().toString()).toMatch(new RegExp('<img' + '/>'));
    });

    it('should handle errors correctly', () => {
      const FailingElement = React.createElement(() => {
        throw new Error('An Error');
      });
      const response = ReactDOMServer.renderToStaticNodeStream(FailingElement);
      return new Promise(resolve => {
        response.once('error', () => {
          resolve();
        });
        expect(response.read()).toBeNull();
      });
    });

    it('should refer users to new apis when using suspense', async () => {
      let resolve = null;
      const promise = new Promise(res => {
        resolve = () => {

Review comment (bug):
this test already existed it was just in the wrong describe block. It now correctly lives in the `renderToNodeStream` block

Code after:
        'renderToNodeStream is deprecated. Use renderToPipeableStream instead.',
        {withoutStack: true},
      );
      expect(response.read().toString()).toMatch(new RegExp('<img' + '/>'));
    });

    it('should handle errors correctly', () => {
      const FailingElement = React.createElement(() => {
        throw new Error('An Error');
      });
      let response;
      expect(() => {
        response = ReactDOMServer.renderToNodeStream(FailingElement);
      }).toErrorDev(
        'renderToNodeStream is deprecated. Use renderToPipeableStream instead.',
        {withoutStack: true},
      );
      return new Promise(resolve => {
        response.once('error', () => {
          resolve();
        });
        expect(response.read()).toBeNull();
      });
    });

    it('should refer users to new apis when using suspense', async () => {
      let resolve = null;
      const promise = new Promise(res => {
        resolve = () => {
          resolved = true;
          res();
        };
      });
      let resolved = false;
      function Suspender() {
        if (resolved) {
          return 'resolved';
        }
        throw promise;
      }

      let response;
      expect(() => {
        response = ReactDOMServer.renderToNodeStream(
          <div>
            <React.Suspense fallback={'fallback'}>
              <Suspender />
            </React.Suspense>
          </div>,
        );
      }).toErrorDev(