profile
viewpoint
Simen Bekkhus SimenB @folio-as Oslo, Norway

facebook/jest 31116

Delightful JavaScript Testing.

siimon/prom-client 1327

Prometheus client for node.js

istanbuljs/istanbuljs 561

monorepo containing the various nuts and bolts that facilitate istanbul.js test instrumentation

af/envalid 478

Environment variable validation for Node.js

istanbuljs/babel-plugin-istanbul 462

A babel plugin that adds istanbul instrumentation to ES6 code

SimenB/add-asset-html-webpack-plugin 287

Add a JavaScript or CSS asset to the HTML generated by html-webpack-plugin

istanbuljs/v8-to-istanbul 51

convert from v8 coverage format to istanbul's format

danielhusar/gulp-stylint 29

Gulp plugin for stylus stylint linter

microsoft/playwright-runner 22

Cross-browser tests with Jest and Playwright

SimenB/babel-preset-es3 8

Preset for Babel's ES3 transformations

delete branch SimenB/docker-node

delete branch : 12-17

delete time in 12 hours

push eventnodejs/docker-node

Simen Bekkhus

commit sha 58bfdf5b81f821cf8f219c06c4dcf09eedbc95a2

Update from 12.16.3 to 12.17.0

view details

Simen Bekkhus

commit sha fd3b96ca4dc2b9a9cee30dd0636bc3b7391e9e6f

Merge pull request #1263 from SimenB/12-17 Update from 12.16.3 to 12.17.0

view details

push time in 12 hours

PR merged nodejs/docker-node

Update from 12.16.3 to 12.17.0

https://nodejs.org/en/blog/release/v12.17.0/

+10 -10

0 comment

7 changed files

SimenB

pr closed time in 12 hours

push eventjest-community/eslint-plugin-jest

Simen Bekkhus

commit sha 3dc34761ab6eac38742ace55c5322d8124e8b403

chore: remove `require` as well

view details

push time in 14 hours

PR opened jest-community/eslint-plugin-jest

Reviewers
fix: remove Jasmine globals

Should remove fail when #595 lands as well.

Documented globals: https://jestjs.io/docs/en/api

+0 -3

0 comment

1 changed file

pr created time in 14 hours

create barnchjest-community/eslint-plugin-jest

branch : SimenB-patch-1

created branch time in 14 hours

PR opened facebook/jest

chore: run esm config test on node 12

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

<!-- Please remember to update CHANGELOG.md in the root of the project if you have not done so. -->

Summary

https://nodejs.org/en/blog/release/v12.17.0/

<!-- Explain the motivation for making this change. What existing problem does the pull request solve? -->

Test plan

Green CI. Circle won't have the new version yet (as it uses docker, and the docker image haven't been updated), but maybe GH Actions will? If not, I'll wait with merging until we can verify the test pass

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->

+1 -2

0 comment

1 changed file

pr created time in 15 hours

create barnchSimenB/jest

branch : mjs-node-12

created branch time in 15 hours

issue commentfacebook/jest

Meta: Native support for ES Modules

Node 12 has been released with unflagged ESM (https://nodejs.org/en/blog/release/v12.17.0/). As noted in the OP though, the APIs Jest use are not unflagged

SimenB

comment created time in 15 hours

PR opened nodejs/docker-node

Update from 12.16.3 to 12.17.0

https://nodejs.org/en/blog/release/v12.17.0/

+10 -10

0 comment

7 changed files

pr created time in 15 hours

create barnchSimenB/docker-node

branch : 12-17

created branch time in 15 hours

push eventnicolo-ribaudo/babel-preset-current-node-syntax

Simen Bekkhus

commit sha de11d9e6f9fb259693679d20b8f36512aff222c8

feat: add import.meta

view details

push time in 21 hours

PR opened nicolo-ribaudo/babel-preset-current-node-syntax

Reviewers
feat: add `import.meta`

https://github.com/facebook/jest/issues/9430#issuecomment-633897142

Stage 4: https://github.com/tc39/proposal-import-meta


Not sure how to tweak the tests to pass - I don't really follow how it works 😅

In node, it's a syntax error outside of modules, so node has to be told to interpret it as a module

+19 -4

0 comment

4 changed files

pr created time in 21 hours

push eventnicolo-ribaudo/babel-preset-current-node-syntax

Simen Bekkhus

commit sha aa9ac8bde7adb4f6d4fd6b7f22529f3643b049d2

feat: add import.meta

view details

push time in 21 hours

issue commentfacebook/jest

Meta: Native support for ES Modules

You need to explicitly opt-out of Babel by using transform: {} as config

SimenB

comment created time in 21 hours

create barnchnicolo-ribaudo/babel-preset-current-node-syntax

branch : import.meta

created branch time in 21 hours

issue commenttypescript-eslint/typescript-eslint

typescript-estree@3.0.0: Supported Typescript Version

https://github.com/typescript-eslint/typescript-eslint/pull/2057

frederikdekegel

comment created time in 2 days

Pull request review commentjest-community/eslint-plugin-jest

Use suggestion instead of fix

 export default createRule({       recommended: false,     },     messages: {+      hasAssertionsTakesNoArguments:+        '`expect.hasAssertions` expects no arguments',+      assertionsRequiresOneArgument:+        '`expect.assertions` excepts a single argument of type number',+      assertionsRequiresNumberArgument: 'This argument should be a number',       haveExpectAssertions:         'Every test should have either `expect.assertions(<number of assertions>)` or `expect.hasAssertions()` as its first expression',+      suggestAddingHasAssertions: 'Add `expect.hasAssertions()`',+      suggestAddingAssertions:+        'Add `expect.assertions(<number of assertions>)`',+      suggestRemovingExtraArguments: 'Remove extra arguments',

can we have some "partially fixable" in the readme?

G-Rath

comment created time in 2 days

pull request commentfacebook/jest

Watchman crawler now includes dotfiles

Ideally we'd crawl dotfiles, but make sure to ignore vcs directories. Stopping to crawl dotfiles for node was to match watchman, not the ideal solution (at least in my mind)

grosto

comment created time in 2 days

issue commentfacebook/jest

Mocking current time for Date

Jest 26 supports mocking Date using modern fake timers: https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers

calebmer

comment created time in 2 days

Pull request review commentmoroshko/react-autosuggest

Merge react-autowhatever in react-autosuggest

     "es6-promise": "^4.2.8",     "prop-types": "^15.7.2",     "react-autowhatever": "^10.2.1",

should this be removed?

aberezkin

comment created time in 2 days

delete branch SimenB/react-textarea-autosize

delete branch : patch-1

delete time in 2 days

PR opened node-modules/agentkeepalive

fix(types): correct `Https` constructor argument

<!-- Thank you for your pull request. Please review below requirements. Bug fixes and new features should include tests and possibly benchmarks. Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md

感谢您贡献代码。请确认下列 checklist 的完成情况。 Bug 修复和新功能必须包含测试,必要时请附上性能测试。 Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md -->

Checklist

<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

  • [ ] npm test passes
  • [ ] tests and/or benchmarks are included
  • [ ] documentation is changed or added
  • [ ] commit message follows commit guidelines
Affected core subsystem(s)

<!-- Provide affected core subsystem(s). -->

Description of change

<!-- Provide a description of the change below this comment. -->

+1 -1

0 comment

1 changed file

pr created time in 3 days

push eventSimenB/agentkeepalive

Simen Bekkhus

commit sha 018fca5f046c3e16bd291eb3ffbf35f89d3a99f9

fix(types): correct `Https` constructor argument

view details

push time in 3 days

fork SimenB/agentkeepalive

Support keepalive http agent.

fork in 3 days

issue commentfacebook/jest

Add moduleNameMapper helper to work with TypeScript path mapping

Won't people who want to re-use mappings from tsconfig be using ts-jest already?

If we are to add anything like this, we should include support for https://webpack.js.org/configuration/resolve/#resolvealias at the same time

ahnpnl

comment created time in 3 days

fork SimenB/patch-package

Fix broken node modules instantly 🏃🏽‍♀️💨

fork in 3 days

PR opened Andarist/react-textarea-autosize

fix: export Props type

We wrap this component at work, and wanna provide our own props based on the abse ones. Exporting it makes it easier to access (and matches what the package on DefinitelyTyped did)

+1 -1

0 comment

1 changed file

pr created time in 3 days

push eventSimenB/react-textarea-autosize

Simen Bekkhus

commit sha 597f6490319d60a13e9ae72486dabf87f865ea41

fix: export Props type

view details

push time in 3 days

push eventSimenB/jest

Tim Seckinger

commit sha 1dc8fcbee7988f947bca48ac85497d010f16b155

property-based test for Node `deepStrictEqual` equivalence (#9167) * property test toStrictEqual vs deepStrictEqual also, import expect so that property tests do not need rebuilds * fix primitives being considered equal to new Primitive()s * update changelog

view details

Will Smythe

commit sha 18dfcbb41965a6c2682e1235b5f76dd071be24a1

Fix missing test results for facebook/jest CI runs in Azure Pipelines (#9177) * Fix missing test result reporting in Azure Pipelines * Fix lint problem in jest.config.ci.js

view details

Simen Bekkhus

commit sha efb311d5440d40806a73003c252ab0a326cd0fc6

chore: bump handlebars

view details

Simen Bekkhus

commit sha ac3f2a50d0e40e70b2246a3a6bb69a51396ea7bd

chore: regenerate lockfiles in e2e tests (#9193)

view details

Simen Bekkhus

commit sha 03b97d6874ad4e35be47437e617395834b9c9201

fix(pretty-format): correctly detect memo (#9196)

view details

Simen Bekkhus

commit sha 4643178d3ab86bc7f8b5f03216c859def81c318b

chore: make changedFiles option optional in `shouldInstrument` (#9197)

view details

Mark Pedrotti

commit sha 8d0b5e2234d378920eb87112933c5c03016fb98e

jest-snapshot: Omit irrelevant received properties when property matchers fail (#9198) * jest-snapshot: Omit irrelevant received properties * Update CHANGELOG.md * Edit comment in test that hash is missing * Edit CHANGELOG.md * Add comment to explain import hack

view details

Mark Pedrotti

commit sha 6bd4e560e288b515ebdf8325f6219522f538dbec

jest-snapshot: Improve colors when snapshots are updatable (#9132) * jest-snapshot: Improve colors when snapshots are updatable * Update CHANGELOG.md * Trailing spaces in changed lines do not need own bg color * Improve convertAnsi to test for trailing spaces in common lines * Make changes requested by Simen and update 2 snapshots * Fix my mistake when resolving merge conflict in yarn.lock * Replace 0x0 with 0 to reduce visual noise * Replace get functions with aSnapshotColor and bReceivedColor * Replace green with teal as Received color

view details

Simen Bekkhus

commit sha 8d3ddd5db440088f4488fbb4aaffe8ae4f5401e5

fix(jest-types): tighten Config types and set more defaults (#9200) * fix(jest-types): tighten Config types and set more defaults * update snaps and make `extraGlobals` optional in `@jest/transform`

view details

Mark Pedrotti

commit sha 7df4cda0043655ad84de3cc262a8f1685c8325f1

jest-snapshot: Ignore indentation for most serialized objects (#9203) * jest-snapshot: Ignore indentation for most serialized objects * Simplify markup delete test * Update CHANGELOG.md * Replace 3 tests with each iteration in dedentLines

view details

Matej Jellus

commit sha be6df92f8b5dfb9283a0a32c83fa6266047f17a3

Fix typo in JestPlatform.md (#9212) Closes #9122

view details

Simen Bekkhus

commit sha fafb5b7b1598693371cc8113d253abf0981209f3

chore: bump to istanbul alphas (#9192)

view details

Jongmun

commit sha ee66670120f1a1d2477c6f4cfa56a58033d9ceb2

docs: remove expect.assertions(1) in rejects example of Tutoria… (#9149) * docs: remove expect.assertions(1) in rejects example of TutorialAsync.md * docs: add a comment for expect.assertions(1) in rejects example of TutorialAsync.md * docs: add a comment for expect.assertions(1) in rejects example of TutorialAsync.md * fix a comment * fix a comment * fix a comment

view details

Simen Bekkhus

commit sha d4e2d84507aee2f90d8a80c2b5020c0f2b3b3662

chore: upgrade to fsevents 2 (#9215)

view details

Ayush Sachdeva

commit sha 670f83ed373c3c17d08f1ec5bd8d57091c46ab56

docs: escape angle brackets in configuration (#9189)

view details

Simen Bekkhus

commit sha f4d0565d70f1ee8e940f126a4a30a174e7f913d2

chore: bump docusaurus to fix blog buttons

view details

Sascha

commit sha 02e8b31f643282858fb651a4a12441bf84f88a6f

Add mongo db example (#7849)

view details

Simen Bekkhus

commit sha bba72c149f09f0124c33e80ad2a11c54893a3548

chore: run tsc and linting as GH action (#9223)

view details

Simen Bekkhus

commit sha edde5110dfe636889fc55342e77d0f7aa2cc8e48

chore: avoid double logging [skip ci]

view details

Frederik Schubert

commit sha 86010d8f88f9e77aa58b701a5b7dc4c8f96b656b

docs: tutorial links updated (#9221)

view details

push time in 4 days

push eventjest-community/jest-react-reporter

Simen Bekkhus

commit sha 074ff80f790e0dc8d741bb9893d59d31825ffe92

fix: disable `esModuleInterop`

view details

push time in 4 days

push eventjest-community/jest-react-reporter

Simen Bekkhus

commit sha 97aa40b02e8b5599b89f7e96b53ed6553fdcbc17

chore: set prettier EOL to auto

view details

push time in 4 days

push eventjest-community/jest-react-reporter

Simen Bekkhus

commit sha f2e12da36d9203af4763e8c805548160e8bd92e6

fix: update dependencies BREAKING CHANGE: drop support for Node 8

view details

Simen Bekkhus

commit sha 8ff117c93c7a9a05b7d7883bac74489bf9d06ee1

fix: use `import type` syntax BREAKING CHANGE: do not emit type information

view details

Simen Bekkhus

commit sha eb4090e6810956c91319f37cae24193b25b5f605

chore: use tsc for building instead of Babel

view details

Simen Bekkhus

commit sha 146370dd6a3a1908766c98b33434261b185ef4c3

fix: build with (patched) ncc This should make sure react runs in production mode for improved performance

view details

push time in 4 days

pull request commentfacebook/jest

fix: remove `require.requireActual` and `require.requireMock`

@arty-name it has jest.requireActual which is not removed

SimenB

comment created time in 5 days

issue commentfacebook/jest

Meta: Native support for ES Modules

I'm wondering if it makes sense to have some "ESM mode" which would add the node esm file extensions and also help with compile-to-js using esm to opt in (#9860).


Without js some stuff internally breaks that we load inside the sandbox. We should probably fix that so the user cannot break us.

SimenB

comment created time in 6 days

issue closedfacebook/jest

SyntaxError: Cannot use import statement outside a module

Hi! Trying to add customSequencer:

import type { Test } from 'jest-runner';
const Sequencer = require('@jest/test-sequencer').default;

class CustomSequencer extends Sequencer {
  sort(tests: Test[]) {
    const orderPath = [
      './../tests/webhooks/authentication.spec.ts',
      './../tests/webhooks/notify-booking-change.spec.ts',
    ];
    return tests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1));
}

export default CustomSequencer;

But, Have an error when run jest command: image

My depencencies:

"dependencies": {
    "@hqoapp/functional-vertical-sdk": "0.0.60",
    "@jest/reporters": "25.2.4",
    "@jest/test-result": "25.2.4",
    "@jest/test-sequencer": "26.0.1",
    "@types/body-parser": "1.19.0",
    "@types/express": "4.17.3",
    "@types/jest": "25.1.4",
    "@types/lodash": "4.14.149",
    "@types/node": "13.9.5",
    "@types/node-ipc": "9.1.2",
    "@types/uuid": "3.4.4",
    "aws-sdk": "2.650.0",
    "axios": "0.19.2",
    "body-parser": "1.19.0",
    "chalk": "4.0.0",
    "class-transformer": "0.2.3",
    "class-validator": "0.11.1",
    "dotenv": "8.2.0",
    "express": "4.17.1",
    "jest": "25.2.4",
    "jest-runner": "26.0.1",
    "lodash": "4.17.15",
    "node-ipc": "9.1.1",
    "reflect-metadata": "0.1.13",
    "start-server-and-test": "1.10.11",
    "ts-jest": "25.3.0",
    "ts-node": "8.8.1",
    "typescript": "3.8.3",
    "uuid": "3.3.2"
  }

closed time in 6 days

pavel-butkevich-98

issue commentfacebook/jest

SyntaxError: Cannot use import statement outside a module

We don't transpile test sequencers, you need to make sure they are CJS.

A PR adding support for transpiling it is welcome, see #8810

pavel-butkevich-98

comment created time in 6 days

issue closedfacebook/jest

How to check that tests already running?

Hi everyone! How can I check using bash or any other way that tests already running?

closed time in 6 days

pavel-butkevich-98

issue commentfacebook/jest

How to check that tests already running?

Please follow the issue template, which includes a section for your use case for such a feature.

http://xyproblem.info/


That said, you can use a reporter to know when tests are running https://jestjs.io/docs/en/configuration#reporters-arraymodulename--modulename-options

pavel-butkevich-98

comment created time in 6 days

issue commentreach/router

Scroll position is not kept on browser back

We're using patch-package with a revert of 1f9f908b13815f98ad3f08c7b3415e8b8c38b8f0

hzr

comment created time in 6 days

issue commentfacebook/jest

Caching problem with --runTestsByPath and 'import' in globalSetup

This is super weird. I've tracked the issue down to this line:

https://github.com/thlorenz/convert-source-map/blob/9e9a7a9b652c30878c9c9aa591d861a9fdf61a7e/index.js#L21

During the first run, SafeBuffer.Buffer is a thing, but during the second run SafeBuffer is an empty object.

Not really sure what's going on... Seeing as removing the globalSetup file works

Full stack trace doesn't really help

image

pahan35

comment created time in 6 days

issue commentfacebook/jest

Meta: Native support for ES Modules

Took a look, and moduleFileExtensions is indeed necessary.

Jest gets a list of all files in the project by running hasteFS.getAllFiles() here:

https://github.com/facebook/jest/blob/2460c059ad1dbf124466ac25c8d5ccfd74ae9f25/packages/jest-core/src/SearchSource.ts#L159-L164

hasteFS is created as part of the HasteMap with the the following extensions config:

https://github.com/facebook/jest/blob/2460c059ad1dbf124466ac25c8d5ccfd74ae9f25/packages/jest-runtime/src/index.ts#L291


However, I don't think it should be necessary to specify moduleFileExtensions in this case though. We already force .snap to be found, should we force well-known JS extensions as well? Those being (off the top of my head) js, mjs, cjs, jsx, ts and tsx? It'll make the crawl slower, but I wouldn't think it has a huge impact. I might be wrong though? As a default it shouldn't be much slower since only cjs and mjs is not part of default patterns already, but for people who have custom patterns it might slow things down?

SimenB

comment created time in 6 days

issue commentfacebook/jest

path.relative appears subtly broken in Jest 25

You could try a "manual dedupe" by just deleting all graceful-fs entries from your lockfile and re-running npm install

ianwremmel

comment created time in 6 days

pull request commentfacebook/jest

feat: allow test environment to run with preset/transform

Feedback from FB that this was potentially very breaking. Code wise still good to go, I'll sync with peeps at FB to make sure we can land it in 27 🙂

Mark1626

comment created time in 7 days

Pull request review commentapollographql/apollo-client

chore(tsc): use `isolatedModules`

 // to work around problems with Map and Set polyfills in older versions of // React Native (which should have been fixed in react-native@0.59.0): // https://github.com/apollographql/apollo-client/pull/5962++export {}

isolatedModules requires every file to be a module

SimenB

comment created time in 7 days

PR opened apollographql/apollo-client

chore(tsc): use `isolatedModules`

<!-- Thanks for filing a pull request on Apollo Client!

A few automated bots may chime in on your PR. They are here to help with reviewing and ensuring Apollo Client is production ready after each pull request merge.

- meteor-bot will respond asking you to sign the CLA if this is your first PR.
  It may also respond with warnings, messages, or fail the build if something is off.
  Don't worry, it'll help you to fix what is broken!

- bundlesize is a status check to keep the footprint of Apollo Client as small as possible.

- travis-ci will run tests, checking style of code, and generally make
  sure everything is working as expected

Please look at the following checklist to ensure that your PR can be accepted quickly: -->

Checklist:

  • [ ] If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • [ ] Make sure all of the significant new logic is covered by tests

isolatedModules emulates more closely Babel's model, where each file can be transpiled in isolation without type information. Main motivation for changing in @apollo/client is that this allows downstream consumers to use isolatedModules as well without disabling type checking of node_modules.

This includes #6317, without which doing isolated modules is pretty much impossible. So please ignore the first commit when reviewing this one.

+276 -257

0 comment

93 changed files

pr created time in 7 days

create barnchSimenB/apollo-client

branch : isolated

created branch time in 7 days

push eventSimenB/apollo-client

Simen Bekkhus

commit sha 54a56fe5c5a7ac017c2a4326a78974a66ea71982

chore: use `import type`

view details

push time in 7 days

PR opened apollographql/apollo-client

chore: use `import type`

<!-- Thanks for filing a pull request on Apollo Client!

A few automated bots may chime in on your PR. They are here to help with reviewing and ensuring Apollo Client is production ready after each pull request merge.

- meteor-bot will respond asking you to sign the CLA if this is your first PR.
  It may also respond with warnings, messages, or fail the build if something is off.
  Don't worry, it'll help you to fix what is broken!

- bundlesize is a status check to keep the footprint of Apollo Client as small as possible.

- travis-ci will run tests, checking style of code, and generally make
  sure everything is working as expected

Please look at the following checklist to ensure that your PR can be accepted quickly: -->

Checklist:

  • [ ] If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • [ ] Make sure all of the significant new logic is covered by tests

This helps strip out imports that aren't used at runtime.

Before: ./dist/apollo-client.cjs.min.js: 23.89KB < maxSize 24KB (gzip After: ./dist/apollo-client.cjs.min.js: 23.88KB < maxSize 24KB (gzip)

So not a huge difference, but it also avoids the footgun where you import some file for types and it ends up running with side effects.

Note that this requires consumers to have at least TS@3.8, not sure if you have a minimum TS version now?

+181 -180

0 comment

71 changed files

pr created time in 7 days

push eventSimenB/apollo-client

Simen Bekkhus

commit sha 368cc1a495b534309822b2fcaa5d45eb99079f33

chore: use `import type`

view details

push time in 7 days

create barnchSimenB/apollo-client

branch : import-type

created branch time in 7 days

issue commentnodejs/node

[Regression in 14.1.0 - Windows] `stdout` is sometimes empty

Could #31860 be reopened?

nicolo-ribaudo

comment created time in 7 days

push eventfacebook/jest

Kenrick

commit sha 2460c059ad1dbf124466ac25c8d5ccfd74ae9f25

Cleanup `displayName` type (#10049)

view details

push time in 7 days

pull request commentfacebook/jest

Cleanup `displayName` type

Thanks!

kenrick95

comment created time in 7 days

PR merged facebook/jest

Cleanup `displayName` type cla signed

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

<!-- Please remember to update CHANGELOG.md in the root of the project if you have not done so. -->

Summary

<!-- Explain the motivation for making this change. What existing problem does the pull request solve? -->

Fixes #10010

If I understand correctly, the type of displayName in ProjectConfig type cannot be a string because it has been normalized, therefore I remove the string type in the DisplayName type. Since InitialOptions can still take in string I add it back there.

The rest is to change the places where displayName is treated as string (i.e. remove such codes because it will never happen)

TODOs:

  • [x] Update CHANGELOG.md
  • [x] Is there any more place that I should change?

Test plan

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->

Check CI results 😅

+12 -20

1 comment

6 changed files

kenrick95

pr closed time in 7 days

issue closedfacebook/jest

Cleanup `displayName` type

I think this is just wrong type in ProjectConfig: https://github.com/facebook/jest/blob/c6e63f331b491082075aef4c48ced355ae72add5/packages/jest-types/src/Config.ts#L87-L92.

We normalize this to an object in jest-config (if passed): https://github.com/facebook/jest/blob/c6e63f331b491082075aef4c48ced355ae72add5/packages/jest-config/src/normalize.ts#L829-L858

So type out should be either object or missing entirely, not a string.

E.g. here it deals with it just being a string, which I'm pretty sure cannot actually happen: https://github.com/facebook/jest/blob/c6e63f331b491082075aef4c48ced355ae72add5/packages/jest-reporters/src/utils.ts#L18-L34

#8612 also introduces some code around this.

closed time in 7 days

SimenB

issue closedfacebook/jest

@jest/globals doesn't seem to work with jest.mock

🐛 Bug Report

When importing jest from @jest/globals, and running jest.mock, I get:

  ● Test suite failed to run

    TypeError: Cannot read property 'jest' of undefined

      2 | import { jest, it, expect } from "@jest/globals";
      3 | // import { it, expect } from "@jest/globals";
    > 4 | jest.mock('./mocked.ts');
        | ^

That's what I get in the minimal reproduction repo. In my regular code, I instead get this error:

ReferenceError: Cannot access 'globals_1' before initialization

To Reproduce

Steps to reproduce the behavior:

  1. git clone git@github.com:Vinnl/ts-jest-repro.git --branch globals-mock (Note that this is not on the master branch.)
  2. npm install
  3. npm test

This is a repository with Jest and ts-jest setup. The problematic code is:

// COMMENT OUT THE (jest) IMPORT TO MAKE THIS WORK AGAIN
import { jest, it, expect } from "@jest/globals";
// import { it, expect } from "@jest/globals";
jest.mock('./mocked.ts');

import { add } from './add';

it('should properly add', () => {
	expect(add(1, 2)).toBe(3);
});

Expected behavior

The test to run successfully.

Link to repl or repo (highly encouraged)

git clone git@github.com:Vinnl/ts-jest-repro.git --branch globals-mock

envinfo

<!-- Run npx envinfo --preset jest Paste the results here: -->

$  npx envinfo --preset jest 
npx: installed 1 in 0.889s

  System:
    OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
  Binaries:
    Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
    Yarn: 1.22.4 - /usr/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
  npmPackages:
    jest: ^26.0.1 => 26.0.1 

closed time in 7 days

Vinnl

issue commentfacebook/jest

@jest/globals doesn't seem to work with jest.mock

Yep, this will only work properly with babel-plugin-jest-hoist (included in babel-jest config). If you use another transformer, that will need to support it

Vinnl

comment created time in 7 days

issue commentbrowserify/resolve

Support ESM resolution

I don't think I've ever seen a nested package.json. Regardless, this isn't the correct issue to discuss it

SimenB

comment created time in 8 days

pull request commentfacebook/jest

[Work In Progress] Async Code Transformation

No particular reason. If it works I'm happy to merge a PR migrating

ychi

comment created time in 8 days

issue commentfacebook/jest

Support for multiple transform scripts

Yeah, I think something like this should work?

"transform": {
    '^.+\\.ts$': ['jest-chain-transformer', {
        transformers: ['custom-transformer', 'ts-jest']
    }]
}
``
We could link it from the docs.

(On mobile, sorry about formatting)
NagRock

comment created time in 8 days

issue commentfacebook/jest

Support for multiple transform scripts

If it's a string it's a transformer and if it's an object it's options to the previous transformer? I guess we could do something like that.

Not sure it's better than a custom transform, though?

NagRock

comment created time in 8 days

pull request commentfacebook/jest

feat: CLI argument to filter tests by projects

Nope.

You can look for it here: https://github.com/facebook/jest/releases

yacinehmito

comment created time in 8 days

issue commentbrowserify/resolve

Support ESM resolution

For the "I need to load package.json" use case, why not do something like this:

const {sync: pkgUp} = require('pkg-up');

const packagePath = pkgUp({ cwd: require.resolve('uuid') });

https://github.com/sindresorhus/pkg-up

Could trivially be packaged up into a pkg-of-module and published to npm

SimenB

comment created time in 8 days

pull request commentjsdom/jsdom

Use clean global when setting up Window

This vmGlobal thing is essentially what the script does at build time

https://github.com/jsdom/jsdom/blob/8921128ee1efe6737e3ea200959eb01fe75ff3aa/scripts/generate-js-globals.js#L14-L16

So this PR partly removes the optimization introduced by having it in a script anyways.

Would it make sense to just do the generate-js-globals thing lazily in the code? Or even not lazily, since running the script (without the write to fs) takes about 35ms

Benchmark #1: node file.js
  Time (mean ± σ):      35.8 ms ±   1.9 ms    [User: 29.9 ms, System: 6.1 ms]
  Range (min … max):    33.3 ms …  42.6 ms    76 runs

Doing runInNewContext rather than creating a context manually and using that is a tiny bit faster, fwiw

Benchmark #1: node file.js
  Time (mean ± σ):      32.7 ms ±   1.6 ms    [User: 27.7 ms, System: 5.2 ms]
  Range (min … max):    30.2 ms …  39.7 ms    90 runs

I don't think those ms will make a huge difference compared to just loading jsdom itself

Benchmark #1: node -e "require(\"jsdom\")"
  Time (mean ± σ):     367.1 ms ±   4.9 ms    [User: 397.9 ms, System: 53.5 ms]
  Range (min … max):   358.6 ms … 375.6 ms    10 runs

This is with inlining the script into the runtime

Benchmark #1: node -e "require(\"jsdom\")"
  Time (mean ± σ):     372.8 ms ±   3.2 ms    [User: 398.7 ms, System: 56.2 ms]
  Range (min … max):   368.1 ms … 378.3 ms    10 runs

So about 5ms slower, but it fixes this bug where global env when js-globals.json is generated differs from the runtime globals

ianschmitz

comment created time in 8 days

pull request commentfacebook/jest

docs: correct confusing filename in `enableAutomock` example

Thanks @duxtinto!

duxtinto

comment created time in 9 days

push eventfacebook/jest

David Hernando Sancha

commit sha 6cef23b50c9a021db147b584ea741fbe65416cef

docs: correct confusing filename in `enableAutomock` example (#10055)

view details

push time in 9 days

PR merged facebook/jest

Reviewers
docs: correct confusing filename in `enableAutomock` example cla signed

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

<!-- Please remember to update CHANGELOG.md in the root of the project if you have not done so. -->

Summary

<!-- Explain the motivation for making this change. What existing problem does the pull request solve? -->

Current example for jest.enableAutomock() functionality uses disableAutomocking.js as the filename for the example test file:

image

it results confusing for the reader.

Test plan

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->

Here you can see a screenshot of the built website after the changes: image

+3 -2

4 comments

3 changed files

duxtinto

pr closed time in 9 days

push eventduxtinto/jest

Simen Bekkhus

commit sha a01b8db073a6de0a94636c37b30fda56fa08266e

Update CHANGELOG.md

view details

push time in 9 days

pull request commentsinonjs/fake-timers

Add stack trace to code recursively scheduling timers

Another though, this is mostly meant to catch timers added while running timers. Could we add some flag internally that's set to true whenever we run timers, and only collect these at that time?

alistairjcbrown

comment created time in 9 days

Pull request review commentsinonjs/fake-timers

Add stack trace to code recursively scheduling timers

 function withGlobal(_global) {         clock.nextTick = function nextTick(func) {             return enqueueJob(clock, {                 func: func,-                args: Array.prototype.slice.call(arguments, 1)+                args: Array.prototype.slice.call(arguments, 1),+                stack: new Error().stack

I meant to still do new Error() here, but only access stack if we actually wanna throw the error

alistairjcbrown

comment created time in 9 days

Pull request review commentsiimon/prom-client

improve performance of registry.metrics()

+'use strict';++const generateFunction = require('generate-function');++function getFormatter(metric, defaultLabels) {+	const defaultLabelNames = Object.keys(defaultLabels);+	const name = metric.name;+	const help = escapeString(metric.help);+	const type = metric.type;+	const labelsCode = getLabelsCode(metric, defaultLabelNames, defaultLabels);++	const gen = generateFunction();+	gen(`+  function format(item, escapeLabelValue, getValueAsString) {+    const info = '# HELP ${name} ${help}\\n# TYPE ${name} ${type}\\n';+    let values = '';+    for (const val of item.values || []) {+      val.labels = val.labels || {};+      let metricName = val.metricName || '${name}';+      const labels = \`${labelsCode}\`;+      const hasLabels = labels.length > 0;+      metricName += \`\${hasLabels ? '{' : ''}\${labels}\${hasLabels ? '}' : ''}\`;+      let line = \`\${metricName} \${getValueAsString(val.value)}\`;+      values += \`\${line}\\n\`;+    }+    return info + values;+  }`);+	return gen.toFunction();+}++function getLabelsCode(metric, defaultLabelNames, defaultLabels) {+	let labelString = '';+	const labelNames = getLabelNames(metric, defaultLabelNames);+	for (let index = 0; index < labelNames.length; index++) {

should add this as a test, no?

doochik

comment created time in 9 days

startedtc39/proposal-compartments

started time in 10 days

issue commentfacebook/jest

ESM Modules implementations leak memory

Thanks @grosto!

SimenB

comment created time in 10 days

issue commentfacebook/jest

NodeEnvironment calls super() without the context parameter

Sorry forgot about this. I think TS only cares about structure, not the name of the arg?

thernstig

comment created time in 10 days

startedtc39/proposal-realms

started time in 10 days

Pull request review commentjest-community/eslint-plugin-jest

Minor fixes

 ruleTester.run('if statements', rule, {     },   ],   invalid: [-    {

👍

G-Rath

comment created time in 10 days

pull request commentsinonjs/fake-timers

Add stack trace to code recursively scheduling timers

Could we just keep track of the last scheduled timer instead of all scheduled timers? Not sure how much that matters

alistairjcbrown

comment created time in 10 days

Pull request review commentsinonjs/fake-timers

Add stack trace to code recursively scheduling timers

 function withGlobal(_global) {         clock.nextTick = function nextTick(func) {             return enqueueJob(clock, {                 func: func,-                args: Array.prototype.slice.call(arguments, 1)+                args: Array.prototype.slice.call(arguments, 1),+                stack: new Error().stack

.stack is potentially somewhat expensive, could we access it lazily in the error case?

alistairjcbrown

comment created time in 10 days

Pull request review commentjest-community/eslint-plugin-jest

Minor fixes

 ruleTester.run('if statements', rule, {     },   ],   invalid: [-    {

why is this deleted?

G-Rath

comment created time in 10 days

Pull request review commentjest-community/eslint-plugin-jest

Use suggestion instead of fix

 export default createRule({           isParsedEqualityMatcherCall(matcher, EqualityMatcher.toEqual)         ) {           context.report({-            fix: fixer => [-              fixer.replaceText(-                matcher.node.property,-                EqualityMatcher.toStrictEqual,-              ),-            ],             messageId: 'useToStrictEqual',             node: matcher.node.property,+            suggest: [

@ts-expect-error in the meantime seems prudent 🙂

G-Rath

comment created time in 10 days

pull request commentjest-community/jest-junit

Updates `jest-validate` to v25.1.0

Jest doesn't ship ESM code, the changelog entry refers to the authoring if the module - it's still transpiled to CJS

opiation

comment created time in 10 days

Pull request review commentjest-community/eslint-plugin-jest

Use suggestion instead of fix

 ruleTester.run('no-test-callback', rule, {     'test("something", function() {})',     'test("something", async function () {})',     'test("something", someArg)',+    'test("something", (...args) => {args[0]();})',

we should error here as well, although we can't apply the fix.

Jest just provides the one argument, so it's just the fixer that doesn't work, with the rule active we should still warn about this case

G-Rath

comment created time in 10 days

Pull request review commentjest-community/eslint-plugin-jest

Use suggestion instead of fix

 export default createRule({           isParsedEqualityMatcherCall(matcher, EqualityMatcher.toEqual)         ) {           context.report({-            fix: fixer => [-              fixer.replaceText(-                matcher.node.property,-                EqualityMatcher.toStrictEqual,-              ),-            ],             messageId: 'useToStrictEqual',             node: matcher.node.property,+            suggest: [

add suggestion: true to the meta.docs field as well

G-Rath

comment created time in 10 days

pull request commentjest-community/eslint-plugin-jest

Deprecate rules

might have been considered breaking, dunno... I have no idea how eslint handles deprecated rules. If it doesn't warn at all I guess it's fine, but then what's the point?

Meh 🤷

G-Rath

comment created time in 11 days

pull request commentjest-community/eslint-plugin-jest

Deprecate rules

Yeah, rebase merge is the way to go 👍

G-Rath

comment created time in 11 days

Pull request review commentfacebook/jest

Rename ProjectConfig.name to ProjectConfig.id

 describe("doesn't bleed module file extensions resolution with multiple workers"      expect(configs).toHaveLength(2); -    const [{name: name1}, {name: name2}] = configs;

keep these, but just call them id instead of name

msurekci

comment created time in 11 days

Pull request review commentfacebook/jest

Cleanup `displayName` type

 export default function getProjectDisplayName(   if (!displayName) {     return undefined;   }-  if (typeof displayName === 'string') {-    return displayName;-  }   if (typeof displayName === 'object') {

it is always an object, so kan remove this if and just return displayName.name

kenrick95

comment created time in 11 days

push eventfacebook/jest

Mikhail Bodrov

commit sha 3bddaf84da445b1f4bab91d16c9fd2f4abba233c

chore: minor optimize getTransformer (#10050)

view details

push time in 11 days

PR merged facebook/jest

chore: minor optimize getTransformer cla signed

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

<!-- Please remember to update CHANGELOG.md in the root of the project if you have not done so. -->

Summary

Minor refactor _getTransformer to avoid needless defining let transform. <!-- Explain the motivation for making this change. What existing problem does the pull request solve? -->

Test plan

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->

+23 -20

0 comment

1 changed file

Connormiha

pr closed time in 11 days

issue commentfacebook/jest

TypeError: _gracefulFs(...).realpathSync.native is not a function

Can we please drop this native junk

What a wonderfully productive way to ensure you get help with your issue

use basic standard library functions?

This is part of Node.js core

https://nodejs.org/api/fs.html#fs_fs_realpathsync_native_path_options

MalauD

comment created time in 12 days

issue commentapollographql/apollo-feature-requests

Apollo Client 3.0 Roadmap

https://github.com/apollographql/apollo-client/commit/0f210391ed9bb0d51dac948f65eb48516f64ecf8

hwillson

comment created time in 12 days

issue commentfacebook/jest

Make jest small

Note it is already an optional dependency (and at FB we blackhole it to an empty package).

Yeah, it should just be a matter of removing it from devDependencies and tweaking the error message to tell people to install it. We do this for weak-napi already

styfle

comment created time in 12 days

issue commentfacebook/jest

make it possible to test.each snapshot or add documentation for it

No - toMatchInlineSnapshot cannot be called in a loop (which is what test.each essentially is)

gwildu

comment created time in 12 days

Pull request review commentfacebook/jest

feat: replace `sane` with `chokidar`

 class HasteMap extends EventEmitter {     let mustCopy = true;      const createWatcher = (root: Config.Path): Promise<Watcher> => {-      // @ts-expect-error: TODO how? "Cannot use 'new' with an expression whose type lacks a call or construct signature."-      const watcher = new Watcher(root, {-        dot: false,-        glob: extensions.map(extension => '**/*.' + extension),-        ignored: ignorePattern,-      });+      const useWatchman = canUseWatchman && this._options.useWatchman;+      const patterns = extensions.map(extension => '**/*.' + extension);+      // Prefer Watchman over Chokidar+      const watcher = useWatchman+        ? new WatchmanWatcher(root, {+            dot: false,+            glob: patterns,+            ignored: ignorePattern,+          })+        : chokidarWatch(patterns, {

I dunno if the ignore pattern works, should probably verify

SimenB

comment created time in 12 days

push eventSimenB/jest

Simen Bekkhus

commit sha 56f5b97374a8d5c1612ca42624186c6f0363cb19

link to pr

view details

push time in 12 days

pull request commentfacebook/jest

feat: replace `sane` with `chokidar`

Hmm, #5387 imports some stuff from sane

image

We should vendor it, I guess

SimenB

comment created time in 12 days

Pull request review commentfacebook/jest

feat: replace `sane` with `chokidar`

 class HasteMap extends EventEmitter {          watcher.once('ready', () => {           clearTimeout(rejectTimeout);-          watcher.on('all', onChange);++          if (useWatchman) {+            watcher.on('all', onChange);+          } else {+            (watcher as ChokidarFsWatcher).on('all', (type, filePath, stat) => {+              onChange(type, filePath, root, stat);+            });

this is the part that makes me think creating some abstraction makes sense. There might be other things we want to tweak as well

SimenB

comment created time in 12 days

PR opened facebook/jest

Reviewers
feat: replace `sane` with `chokidar`

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

<!-- Please remember to update CHANGELOG.md in the root of the project if you have not done so. -->

Summary

sane pulls in old version of micromatch. We're also already vendoring their watchman watcher (#5387) and the fsevents watcher they removed (#8258). Replacing with chokidar allows us to drop that last vendoring as chokidar abstracts over it.

We might need to create a chokidar abstraction here, I just did the minimal to make it work.

This is very untested

<!-- Explain the motivation for making this change. What existing problem does the pull request solve? -->

Test plan

Dunno. It works for the simple cases I played with locally, but it needs real usage.

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->

+41 -252

0 comment

7 changed files

pr created time in 12 days

more