clitests_helper.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* Copyright 2018 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. import { setVerbosityLevel, VerbosityLevel } from "../../src/shared/util.js";
  16. import { isNodeJS } from "../../src/shared/is_node.js";
  17. import { PDFNodeStream } from "../../src/display/node_stream.js";
  18. import { setPDFNetworkStreamFactory } from "../../src/display/api.js";
  19. // Sets longer timeout, similar to `jasmine-boot.js`.
  20. jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
  21. // Ensure that this script only runs in Node.js environments.
  22. if (!isNodeJS) {
  23. throw new Error(
  24. "The `gulp unittestcli` command can only be used in Node.js environments."
  25. );
  26. }
  27. // Reduce the amount of console "spam", by ignoring `info`/`warn` calls,
  28. // when running the unit-tests in Node.js/Travis.
  29. setVerbosityLevel(VerbosityLevel.ERRORS);
  30. // Set the network stream factory for the unit-tests.
  31. setPDFNetworkStreamFactory(function (params) {
  32. return new PDFNodeStream(params);
  33. });