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

#3087: Implement reactjs + javascript unit tests #3235

Merged
merged 161 commits into from
May 31, 2018
Merged

Conversation

jeff1evesque
Copy link
Owner

Resolves #3087.

@jeff1evesque
Copy link
Owner Author

jeff1evesque commented May 31, 2018

Our manual implementation of the browserify container, via our npm test script, shows that jest produced a nonempty lcov.info:

root@browserify:/var/machine-learning/src/jsx# ls -l
total 360
-rwxrwxrwx    1 root root   1013 May 20 17:03 README.md
drwxrwxrwx    4 root root   4096 May 31 03:57 __tests__
-rwxrwxrwx    1 root root   1291 May 20 17:03 content.jsx
drwxr-xr-x    2 root root   4096 May 31 16:07 dockerfile
-rwx--x---    1 root root     82 May 31 16:11 entrypoint
drwxrwxrwx   17 root root   4096 May 31 03:57 import
-rwxrwxrwx    1 root root    244 May 31 03:57 jest.config.js
drwxr-xr-x 1352 root root  32768 May 31 16:11 node_modules
-rw-r--r--    1 root root 298268 May 31 16:11 package-lock.json
-rwxrwxrwx    1 root root   1613 May 31 16:11 package.json
-rwxrwxrwx    1 root root   2884 May 31 03:57 setup.js
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx# ls -l node_modules/coveralls/bin
total 4
-rwxr-xr-x 1 root root 388 May 31 16:58 coveralls.js
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx# npm run test

> reactjs@1.0.0 test /var/machine-learning/src/jsx
> NODE_ENV=test jest --config jest.config.js

 PASS  __tests__/layout/analysis.test.jsx (29.896s)
  AnalysisLayout Component
    ✓ analysisForm should exist (10ms)
    ✓ url should render DataNewState component (76ms)
    ✓ url should render DataAppendState component (33ms)
    ✓ url should render ModelGenerateState component (58ms)
    ✓ url should render ModelPredictState component (9ms)
    ✓ url should render CurrentResultState component (16ms)
    ✓ url should render ResultsDisplayState component (12ms)

 PASS  __tests__/layout/page.test.jsx (16.901s)
  PageLayout Component
    ✓ should render home route (173ms)
    ✓ should render login route (28ms)
    ✓ should render logout route (13ms)
    ✓ should render register route (24ms)
    ✓ should render analysis route (40ms)

 PASS  __tests__/content/register.test.jsx
  Register Component
    ✓ registerForm should exist (3ms)
    ✓ user[login] field should exist (8ms)
    ✓ [name="user[email]"] field should exist (2ms)
    ✓ [name="user[password]"] field should exist (2ms)
    ✓ submit buttom should exist (2ms)

 PASS  __tests__/content/login.test.jsx
  Login Component
    ✓ loginForm should exist (2ms)
    ✓ user[login] field should exist (4ms)
    ✓ user[password] field should exist (3ms)
    ✓ form submit button should exist (2ms)

----------------------------------|----------|----------|----------|----------|-------------------|
File                              |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------------------------------|----------|----------|----------|----------|-------------------|
All files                         |    34.02 |    21.06 |    36.79 |    34.25 |                   |
 jsx                              |    51.06 |     7.14 |    23.53 |    53.33 |                   |
  setup.js                        |    51.06 |     7.14 |    23.53 |    53.33 |... 68,73,76,77,79 |
 jsx/import/animation             |    79.17 |       55 |    64.29 |    79.17 |                   |
  animate.jsx                     |    79.17 |       55 |    64.29 |    79.17 |... 34,135,136,139 |
 jsx/import/content               |    26.85 |    17.44 |       50 |    26.85 |                   |
  home-page.jsx                   |      100 |      100 |      100 |      100 |                   |
  login.jsx                       |    27.78 |    22.58 |    55.56 |    27.78 |... 46,156,169,183 |
  register.jsx                    |    23.91 |    14.55 |    33.33 |    23.91 |... 99,209,219,231 |
 jsx/import/formatter             |        0 |      100 |        0 |        0 |                   |
  transpose.js                    |        0 |      100 |        0 |        0 |    47,48,51,52,57 |
 jsx/import/general               |    35.71 |    15.38 |    27.27 |    36.59 |                   |
  ajax-caller.js                  |    53.85 |       50 |       60 |    58.33 |    16,44,46,49,53 |
  breakpoints.js                  |      100 |      100 |      100 |      100 |                   |
  colors.js                       |      100 |      100 |      100 |      100 |                   |
  range-slider.jsx                |        0 |        0 |        0 |        0 |... 62,63,64,65,67 |
  spinner.jsx                     |       50 |      100 |        0 |       50 |                14 |
  submit-button.jsx               |        0 |        0 |        0 |        0 |    23,24,25,26,28 |
 jsx/import/input-data            |        0 |        0 |        0 |        0 |                   |
  supply-dataset-file.jsx         |        0 |        0 |        0 |        0 |... 8,90,95,96,113 |
  supply-dataset-url.jsx          |        0 |        0 |        0 |        0 |... 6,88,93,94,112 |
  supply-predictors.jsx           |        0 |        0 |        0 |        0 |... 11,118,119,121 |
 jsx/import/layout                |    34.21 |    19.51 |    73.33 |    34.21 |                   |
  analysis.jsx                    |    30.56 |    19.51 |    69.23 |    30.56 |... 33,234,254,281 |
  login.jsx                       |      100 |      100 |      100 |      100 |                   |
  register.jsx                    |      100 |      100 |      100 |      100 |                   |
 jsx/import/model                 |       50 |        0 |    66.67 |       50 |                   |
  model-type.jsx                  |       50 |        0 |    66.67 |       50 |       27,28,29,31 |
 jsx/import/navigation            |     3.64 |        0 |     6.25 |     3.64 |                   |
  header-menu.jsx                 |        0 |        0 |        0 |        0 |... 35,143,150,151 |
  nav-bar.jsx                     |      100 |      100 |      100 |      100 |                   |
  user-menu.jsx                   |        0 |        0 |        0 |        0 |... 28,229,231,248 |
 jsx/import/navigation/menu-items |    23.33 |    15.09 |    33.33 |    23.33 |                   |
  current-result.jsx              |       50 |      100 |        0 |       50 |                15 |
  home.jsx                        |       50 |      100 |        0 |       50 |                17 |
  login.jsx                       |        0 |        0 |        0 |        0 |... 20,123,132,133 |
  register.jsx                    |        0 |        0 |        0 |        0 |    25,30,40,44,45 |
  results.jsx                     |    52.17 |    44.44 |    83.33 |    52.17 |... 63,64,67,68,92 |
 jsx/import/redux                 |      100 |      100 |      100 |      100 |                   |
  store.jsx                       |      100 |      100 |      100 |      100 |                   |
 jsx/import/redux/action          |    23.08 |        0 |       30 |    23.08 |                   |
  current-result.jsx              |        0 |      100 |        0 |        0 |                 7 |
  login.jsx                       |        0 |      100 |        0 |        0 |                 7 |
  logout.jsx                      |        0 |      100 |        0 |        0 |                 9 |
  page.jsx                        |       30 |        0 |    42.86 |       30 |... 26,56,57,62,63 |
 jsx/import/redux/container       |       70 |     38.6 |    68.18 |       70 |                   |
  analysis-layout.jsx             |    63.64 |    33.33 |      100 |    63.64 |... 38,42,43,46,47 |
  current-result.jsx              |       80 |    57.14 |      100 |       80 |             29,30 |
  data-append.jsx                 |      100 |      100 |      100 |      100 |                   |
  data-new.jsx                    |      100 |      100 |      100 |      100 |                   |
  header-menu.jsx                 |    66.67 |      100 |        0 |    66.67 |                18 |
  home-page.jsx                   |      100 |      100 |      100 |      100 |                   |
  login-link.jsx                  |     37.5 |        0 |        0 |     37.5 |    19,20,22,26,35 |
  login.jsx                       |     87.5 |       80 |      100 |     87.5 |                22 |
  model-generate.jsx              |      100 |      100 |      100 |      100 |                   |
  model-predict.jsx               |      100 |      100 |      100 |      100 |                   |
  range-slider.jsx                |    66.67 |      100 |        0 |    66.67 |                18 |
  register-link.jsx               |    33.33 |        0 |        0 |    33.33 |       18,19,21,25 |
  register.jsx                    |     87.5 |       80 |      100 |     87.5 |                21 |
  results.jsx                     |      100 |      100 |      100 |      100 |                   |
  review-results-link.jsx         |    66.67 |    57.14 |      100 |    66.67 |             22,23 |
  user-menu.jsx                   |     37.5 |        0 |        0 |     37.5 |    19,20,22,26,35 |
 jsx/import/redux/reducer         |    59.52 |     57.5 |      100 |    59.52 |                   |
  data.jsx                        |     37.5 |    36.36 |      100 |     37.5 |    17,18,20,22,29 |
  layout.jsx                      |     87.5 |    90.91 |      100 |     87.5 |                38 |
  login.jsx                       |     62.5 |    55.56 |      100 |     62.5 |          16,23,25 |
  page.jsx                        |    55.56 |    44.44 |      100 |    55.56 |... 32,41,43,69,77 |
 jsx/import/result                |    31.54 |    32.32 |    43.48 |    31.54 |                   |
  current-result.jsx              |    22.11 |    34.15 |    31.25 |    22.11 |... 80,343,346,349 |
  results.jsx                     |    57.14 |    23.53 |    71.43 |    57.14 |... 99,114,115,132 |
 jsx/import/route                 |      100 |      100 |      100 |      100 |                   |
  main-route.jsx                  |      100 |      100 |      100 |      100 |                   |
  result-route.jsx                |      100 |      100 |      100 |      100 |                   |
  session-route.jsx               |      100 |      100 |      100 |      100 |                   |
 jsx/import/session-type          |    38.46 |    14.38 |    43.75 |    38.46 |                   |
  data-append.jsx                 |    43.94 |     18.6 |    46.15 |    43.94 |... 93,196,197,243 |
  data-new.jsx                    |    39.62 |     8.33 |       40 |    39.62 |... 32,136,137,153 |
  model-generate.jsx              |    30.38 |    10.64 |    35.71 |    30.38 |... 18,224,230,280 |
  model-predict.jsx               |    41.94 |    22.22 |    54.55 |    41.94 |... 49,154,165,195 |
 jsx/import/svg                   |        0 |        0 |        0 |        0 |                   |
  svg-books.jsx                   |        0 |      100 |        0 |        0 |... 20,21,25,29,33 |
  svg-home.jsx                    |        0 |        0 |        0 |        0 |... 32,36,40,44,48 |
  svg-pencil-note.jsx             |        0 |      100 |        0 |        0 |... 21,22,26,30,34 |
  svg-user.jsx                    |        0 |      100 |        0 |        0 |... 20,21,25,29,33 |
 jsx/import/validator             |    10.71 |    21.43 |    16.67 |    10.71 |                   |
  valid-email.js                  |        0 |      100 |        0 |        0 |            6,7,11 |
  valid-file.js                   |        0 |        0 |        0 |        0 |       6,7,8,10,15 |
  valid-float.js                  |        0 |        0 |        0 |        0 |... 16,17,19,22,27 |
  valid-password.js               |        0 |      100 |        0 |        0 |          10,11,15 |
  valid-string.js                 |       75 |       75 |      100 |       75 |                 9 |
  valid-url.js                    |        0 |      100 |        0 |        0 |            6,7,11 |
----------------------------------|----------|----------|----------|----------|-------------------|
Test Suites: 4 passed, 4 total
Tests:       21 passed, 21 total
Snapshots:   0 total
Time:        53.987s
Ran all test suites.
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx# ls -l
total 752
-rwxrwxrwx    1 root root   1013 May 31 16:11 README.md
drwxrwxrwx    6 root root   4096 May 31 16:11 __tests__
-rw-r--r--    1 root root  87903 May 31 16:13 clover.xml
-rwxrwxrwx    1 root root   1291 May 31 16:11 content.jsx
-rw-r--r--    1 root root 255147 May 31 16:13 coverage-final.json
drwxr-xr-x    2 root root   4096 May 31 16:07 dockerfile
-rwx--x---    1 root root     82 May 31 16:11 entrypoint
drwxrwxrwx   32 root root   4096 May 31 16:11 import
-rwxrwxrwx    1 root root    235 May 31 16:11 jest.config.js
drwxr-xr-x    3 root root   4096 May 31 16:13 lcov-report
-rw-r--r--    1 root root  41240 May 31 16:13 lcov.info
drwxr-xr-x 1459 root root  36864 May 31 16:11 node_modules
-rw-r--r--    1 root root 298268 May 31 16:11 package-lock.json
-rwxrwxrwx    1 root root   1613 May 31 16:11 package.json
-rwxrwxrwx    1 root root   2787 May 31 16:11 setup.js
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx#
root@browserify:/var/machine-learning/src/jsx# ls -l node_modules/coveralls/bin
total 4
-rwxr-xr-x 1 root root 388 May 31 16:58 coveralls.js

Therefore, subsequent test:coveralls builds, should also yield a similar nonempty lcov.info.

@jeff1evesque
Copy link
Owner Author

A local implementation within our browserify container, yields the same results are travis build:

root@browserify:/var/machine-learning/src/jsx# npm run test:coveralls

> reactjs@1.0.0 test:coveralls /var/machine-learning/src/jsx
> npm run test --coverage --coverageReporters=lcov.info | ./node_modules/coveralls/bin/coveralls.js

Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! reactjs@1.0.0 test: `NODE_ENV=test jest --config jest.config.js`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the reactjs@1.0.0 test 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!     /root/.npm/_logs/2018-05-31T17_00_36_780Z-debug.log
[error] "2018-05-31T17:00:37.948Z"  'error from lcovParse: ' 'Failed to parse string'
[error] "2018-05-31T17:00:37.963Z"  'input: ' '\n> reactjs@1.0.0 test /var/machine-learning/src/jsx\n> NODE_ENV=test jest --config jest.config.js\n\n'
[error] "2018-05-31T17:00:37.966Z"  'error from convertLcovToCoveralls'

/var/machine-learning/src/jsx/node_modules/coveralls/bin/coveralls.js:18
        throw err;
        ^
Failed to parse string
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs@1.0.0 test:coveralls: `npm run test --coverage --coverageReporters=lcov.info | ./node_modules/coveralls/bin/coveralls.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjs@1.0.0 test:coveralls 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!     /root/.npm/_logs/2018-05-31T17_00_38_092Z-debug.log

Upon reviewing the corresponding /root/.npm/_logs/2018-05-31T17_00_38_092Z-debug.log:

root@browserify:/var/machine-learning/src/jsx# cat /root/.npm/_logs/2018-05-31T17_00_38_092Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test:coveralls' ]
2 info using npm@5.6.0
3 info using node@v9.11.1
4 verbose run-script [ 'pretest:coveralls', 'test:coveralls', 'posttest:coveralls' ]
5 info lifecycle reactjs@1.0.0~pretest:coveralls: reactjs@1.0.0
6 info lifecycle reactjs@1.0.0~test:coveralls: reactjs@1.0.0
7 verbose lifecycle reactjs@1.0.0~test:coveralls: unsafe-perm in lifecycle true
8 verbose lifecycle reactjs@1.0.0~test:coveralls: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/machine-learning/src/jsx/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle reactjs@1.0.0~test:coveralls: CWD: /var/machine-learning/src/jsx
10 silly lifecycle reactjs@1.0.0~test:coveralls: Args: [ '-c',
10 silly lifecycle   'npm run test --coverage --coverageReporters=lcov.info | ./node_modules/coveralls/bin/coveralls.js' ]
11 silly lifecycle reactjs@1.0.0~test:coveralls: Returned: code: 1  signal: null
12 info lifecycle reactjs@1.0.0~test:coveralls: Failed to exec test:coveralls script
13 verbose stack Error: reactjs@1.0.0 test:coveralls: `npm run test --coverage --coverageReporters=lcov.info | ./node_modules/coveralls/bin/coveralls.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:180:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:180:13)
13 verbose stack     at maybeClose (internal/child_process.js:936:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid reactjs@1.0.0
15 verbose cwd /var/machine-learning/src/jsx
16 verbose Linux 3.13.0-149-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test:coveralls"
18 verbose node v9.11.1
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error reactjs@1.0.0 test:coveralls: `npm run test --coverage --coverageReporters=lcov.info | ./node_modules/coveralls/bin/coveralls.js`
22 error Exit status 1
23 error Failed at the reactjs@1.0.0 test:coveralls script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@jeff1evesque
Copy link
Owner Author

The corresponding coveralls decrease for this PR is indicative that we have succeeded with the intended changes, associated with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants