Skip to content

Commit

Permalink
fix #449: integration tests now import the built quagga module rather…
Browse files Browse the repository at this point in the history
… than the unbuilt source code

- fix npm run cypress:open by adjusting src/config/config.ts
  • Loading branch information
ericblade committed Sep 20, 2022
1 parent 3ed50f6 commit 63350e9
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"coverage:node": "// DOES NOT WORK YET // npx cross-env NODE_ENV=test BUILD_ENV=development nyc --no-clean ts-mocha -p test/tsconfig.json src/**/test/node/*.spec.* src/**/test/*.spec.*",
"coverage": "npm run cypress:run",
"cypress:open": "npx cross-env NODE_ENV=development BUILD_ENV=development cypress open --env BUILD_ENV=development",
"cypress:run": "npx cross-env NODE_ENV=test BUILD_ENV=development cypress run --env BUILD_ENV=development",
"cypress:run": "npx cross-env NODE_ENV=development BUILD_ENV=development cypress run --env BUILD_ENV=development",
"test:browser-specific": "NOT WORKING -- something like npx cypress run --config testFiles=[browser]",
"test:browser-universal": "NOT WORKING -- something like npx cypress run --config testFiles=[universal]",
"test:browser-all": "npm run cypress:run",
Expand Down
20 changes: 12 additions & 8 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import DevConfig from './config.dev';
import NodeConfig from './config.node';
import ProdConfig from './config.prod';

// @ts-ignore // TODO: this produces a bizarre typescript error
// eslint-disable-next-line no-nested-ternary
const QuaggaConfig: QuaggaJSConfigObject = ENV.development
? DevConfig
: ENV.node
? NodeConfig
: ProdConfig;
const ExportConfig: QuaggaJSConfigObject = (() => {
let QuaggaConfig: QuaggaJSConfigObject;
if (typeof ENV === 'undefined' || ENV.development) {
QuaggaConfig = DevConfig;
} else if (ENV.node) {
QuaggaConfig = NodeConfig;
} else {
QuaggaConfig = ProdConfig;
}
return QuaggaConfig;
})();

export default QuaggaConfig;
export default ExportConfig;
1 change: 1 addition & 0 deletions src/input/frame_grabber.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Interp2D = require('ndarray-linear-interpolate').d2;
const FrameGrabber = {};

FrameGrabber.create = function (inputStream, canvas) {
// console.warn('*** FrameGrabberNode create()');
const _that = {};
const _videoSize = CVUtils.imageRef(inputStream.getRealWidth(), inputStream.getRealHeight());
const _canvasSize = inputStream.getCanvasSize();
Expand Down
1 change: 1 addition & 0 deletions src/input/frame_grabber_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function adjustCanvasSize(canvas, targetSize) {
const FrameGrabber = {};

FrameGrabber.create = function (inputStream, canvas) {
// console.warn('*** FrameGrabberBrowser create');
const _that = {};
const _streamConfig = inputStream.getConfig();
const _videoSize = imageRef(inputStream.getRealWidth(), inputStream.getRealHeight());
Expand Down
1 change: 1 addition & 0 deletions src/input/input_stream/input_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const inputStreamFactory: InputStreamFactory = {
throw new Error('createLiveStream not available');
},
createImageStream(): InputStream {
// console.warn('* InputStreamNode createImageStream');
let _config: { mime: string; size: number; src: any } | null = null;

let width = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/input/input_stream/input_stream_browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { InputStreamFactory, InputStream, EventHandlerList } from './input_strea

const inputStreamFactory: InputStreamFactory = {
createVideoStream(video): InputStream {
console.warn('**** InputStreamBrowser createVideoStream');
let _config: { size: number; type: string } | null = null;
const _eventNames = ['canrecord', 'ended'];
const _eventHandlers: EventHandlerList = {};
Expand Down Expand Up @@ -149,6 +150,7 @@ const inputStreamFactory: InputStreamFactory = {
return inputStream;
},
createLiveStream(video): InputStream {
console.warn('**** InputStreamBrowser createLiveStream');
if (video) {
video.setAttribute('autoplay', 'true');
}
Expand All @@ -159,6 +161,7 @@ const inputStreamFactory: InputStreamFactory = {
return that;
},
createImageStream(): InputStream {
// console.warn('**** InputStreamBrowser createImageStream');
let _config: { size: number; sequence: any } | null = null;

let width = 0;
Expand Down
3 changes: 2 additions & 1 deletion test/integration/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// a single image to be returned.
// TODO: write a test that allows for locate: false and locator configs to be tested.

import Quagga from '../../src/quagga';
// import Quagga from '../../src/quagga';
import Quagga from '../../';
import { QuaggaJSConfigObject } from '../../type-definitions/quagga';
import { expect } from 'chai';
import ExternalCode128Reader from '../../src/reader/code_128_reader';
Expand Down

0 comments on commit 63350e9

Please sign in to comment.