Git Product home page Git Product logo

jester's People

Contributors

david-kunz avatar joaovfsousa avatar tapayne88 avatar treipatru avatar vuki656 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jester's Issues

Cannot reuse the same window

Looking at #8 I was expecting that if I re-ran the command it would re-use the same terminal window.

If I run

:lua require"jester".run()```

it will run the tests, if I then move back to my test code and run the command again, it navigates me to the test terminal split, but does not run anything again.

The escaping characters in $file breaks the run command on MacOS

The character escaping breaks the run command for me on MacOS. Escaping probably makes sense on Windows, but on MacOS it seems to be redundant and unneeded. I think it would be great to add a special option to not escape characters in cmd.

This is probably related to the #7 issue

Can't find nearest test when cursor is on a comment

Nice plugin!

I'm experimenting with this in a TypeScript project and noticed what may be a little bug. If the cursor is directly over a comment, then it seems like it is unable to traverse the parent nodes to find the nearest "test" block. But moving anywhere else inside the test function locates it perfectly fine.

Fails to run tests with - in their name

This is basically a copy of #10. I commented there, but given it's closed, it might get lost so just repeating that here:

I can share what is being run on my case:

npx sfdx-lwc-jest -- -t '^c\\-api\\-data\\-fetcher does not display success or error messages when loading$' /home/fede/P
rogramming/Salesforce/one\\-customer\\-care\\-sfdc/force\\-app/main/default/lwc/apiDataFetcher/__tests__/apiDataFetcher\\.test\\.js

Please note the npx sfdx-lwc-jest -- is a wrapper around jest, but works fine if the dashes are not double escaped:
npx sfdx-lwc-jest -- -t '^c-api-data-fetcher does not display' force-app/main/default/lwc/apiDataFetcher/__tests__/apiDataFetcher.test.js works fine (I dropped the $, but it just ends up running multiple tests)

This is my config:

return {
    'David-Kunz/jester',
    config = function()
        require('jester').setup {
            cmd = "npx sfdx-lwc-jest -- -t '$result' $file",
            prepend = { 'describe' },
            terminal_cmd = ":ToggleTerm direction=float"
        }
    end
}

Replicated in bash and zsh. Both in and out of tmux, and both in alacritty and gnome-terminal.

Let me know what other info I can get for you.

Could not find any of the following: test, it, describe

I created an Angular application which offered 3 tests by default:
ng new ng-dummy

I then could run the tests from the command line:

11:12 $ ng test
โœ” Browser application bundle generation complete.
19 06 2022 11:12:59.914:WARN [karma]: No captured browser, open http://localhost:9876/
19 06 2022 11:12:59.931:INFO [karma-server]: Karma v6.3.20 server started at http://localhost:9876/
19 06 2022 11:12:59.932:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
19 06 2022 11:12:59.936:INFO [launcher]: Starting browser Chrome
19 06 2022 11:13:01.190:INFO [Chrome 102.0.5005.115 (Linux x86_64)]: Connected on socket rEYPsN7y3S_ui1boAAAB with id 55219348
Chrome 102.0.5005.115 (Linux x86_64): Executed 3 of 3 SUCCESS (0.213 secs / 0.164 secs)
TOTAL: 3 SUCCESS
Chrome 102.0.5005.115 (Linux x86_64) ERROR
  Disconnected Client disconnected from CONNECTED state (transport close)
Chrome 102.0.5005.115 (Linux x86_64): Executed 3 of 3 SUCCESS (0.213 secs / 0.164 secs)
Chrome 102.0.5005.115 (Linux x86_64) ERROR
  Disconnected Client disconnected from CONNECTED state (transport close)

I was hopping to run them from within nvim:

use "David-Kunz/jester"

local status_ok, jester = pcall(require, "jester")    
if not status_ok then    
  return    
end      
jester.setup {    
}

With the current cursor location in the body of one test, I typed in the command:
:lua require"jester".run()

But it did not run the test. Instead of displayed the message:
Could not find any of the following: test, it, describe

Angular CLI: 13.3.3
Node: 16.14.2
Package Manager: npm 8.5.0
OS: linux x64
14:01 $ nvim --version
NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az316-460

Integrate with rcarriga/nvim-dap-ui repl window?

I'm really loving jester, so a huge thanks for all the work you've put into it. :-)

Basically, what I'd like to do is put jester's terminal output into the nvim-dap-ui repl window. All the other debug windows from the dap-ui work perfectly (stacks, breakpoints, scopes) with Jester, but the repl window stays blank. I've tried to figure out how to pipe the terminal output from jester into that window (running lua require"jester".debug({ terminal_cmd =}) with lots of different options, but none seem to work.

Any direction on how this might be possible? I can definitely rearrange the jester terminal window to fit the layout, but that cuts into the flow of coding, so I'd like to find an automated solution. Thanks again!

Example Typescript Conifg

Trying to get this to work with typescript. Is it asking too much to post a sample typescript config? Thank you.

Debugger starts always the first debugged test

As nvim-dap repo suggests to use vscode-dap I have switched to vscode-dap. Also I have adjusted jester setup a accordingly. Here is my jester setup.

require'jester'.setup{
  cmd = "NODE_OPTIONS=--experimental-vm-modules node ./node_modules/jest/bin/jest.js -t \"$result\" $file", -- run command
  terminal_cmd = ":ToggleTerm",
  dap = {
    type = 'pwa-node',
    request = 'launch',
    name = 'Jest Debug',
    cwd = "${workspaceFolder}",
    rootPath = "${workspaceFolder}",
    runtimeExecutable = "node",
    runtimeArgs = {
      "./node_modules/jest/bin/jest.js",
      "--runInBand",
      "-t",
      "$result",
      "$file",
    },
    -- args = { "--runTestsByPath", "${relativeFile}" },
    args = { "--no-cache" },
    env = { NODE_OPTIONS = '--experimental-vm-modules' },
    sourceMaps = true,
    skipFiles = { "<node_internals>/**" },
    port=9229,
    console = 'integratedTerminal',
    disableOptimisticBPs = true
  },
}

also I have following mappings

nnoremap <silent> <leader>jr :lua require"jester".run()<CR>
nnoremap <silent> <leader>jd :lua require"jester".debug()<CR>

jester.run() works like expected by jester.debug() executes always the first debugged test. I always need to restart nvim to be able to debug second test.

Can't find tests when the filename has regex symbols in it

Hi ๐Ÿ‘‹ As the title says, can't find tests when the filename has regex symbols in it. For example, one of my projects has a filename like [productType].test.tsx which is a perfectly valid filename in a Node/TS project.

I can run this test from command line:

> yarn jest src/pages/some-page/__tests__/\\[productType\\].test.tsx

But when running from Jester, it can't find the test likely because it interpreted [productType] as a regex character class, instead of just a plain string. No escaping is done before passing the filename to Jest.

Debugger listening on ws://127.0.0.1:9229/5ddc50
f6-7908-4b7d-9b34-7fc41391553e
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /Users/kahnclusions/src/myproject
  607 files checked.
  testMatch: **/?(*.)+(spec|test).[tj]s?(x) - 52
 matches
  testPathIgnorePatterns: /node_modules/ - 607 matches
  testRegex:  - 0 matches
Pattern: /Users/kahnclusions/src/myproject/src/pages/some-page/__tests__/[productType].test.tsx|--no-cache - 0 matches
Waiting for the debugger to disconnect...

[Process exited 137]

Support running debugger through yarn

Yarn (and maybe other package managers) support different ways of storing dependancies. This makes the local node modules not compliant in those cases. https://yarnpkg.com/features/pnp/#initializing-pnp

For example running :lua require"jester".debug()

Debugger listening on ws://127.0.0.1:9229/08a2389d-5a16-4aed-9437-48d1d61740d3
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module '/home/rockerboo/code/ecogarden/create/node_modules/.bin/jest'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

[Process exited 1]

The suggestion is to run yarn run --inspect --inspect-brk jest instead. This will look up the binary and apply the inspects for the debugger.

I think with this example it starts running a node process so would need to pass through the suggested paths

node -r ./.pnp.cjs ./server.js
NODE_OPTIONS="--require $(pwd)/.pnp.cjs" node ./server.js

I am also working with yarn workspaces so these 2 modes are not generally good enough to automate depending on where I am in the workspaces.

LSP workspace folder

Hi @David-Kunz ,

Would you be interested into adding the workspace folder automatically by adding lsp dependency to the package ? I was struggling to setup up the path correctly for running the commands while now lsp can get the workspace folder automatically.

I have the code ready on my local copy just wondering if you are intersted into adding it into yours

General Question

Hi, great work with this plugin! Does this work for TS projects?

How to override CMD and run both files and specific tests?

I am using create-react-app so need to override the cmd to make sure it's loaded correctly.

require("jester").setup({
  cmd = "NODE_PATH=. react-scripts test --testPathPattern=$file --testNamePattern='$result'",
})

This works great for

:lua require"jester".run()

But it breaks

:lua require"jester".run_file()

because it tries to filter test names matching /$result/

Missing "dap" module?

When running :lua require"jester".debug_file():

init.lua:154: module 'dap' not found:

Could not find a 'dap' module in src code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.