With PhpStorm, you can choose whether to use npm, Yarn, Yarn 2, or pnpm in a project. By default, PhpStorm suggests npm. However if you open a project with a yarn.lock file and Yarn is installed on your computer, PhpStorm automatically changes the package manager for this project to Yarn. PhpStorm is now listening to debug connections from your Frontastic Machine. You just need to tell PhpStorm where you want to start debugging by setting a breakpoint. In the below example, we're just using the index.php for this, but you could set it up for any PHP code in the Frontastic platform, including your custom PHP code.
Early Access ProgramWebStorm 2019.3 Early Preview build #9 is now available!
If you’re unfamiliar with our Early Access Program or if you want to catch up on all the new features, check out the previous EAP blog posts.
The Toolbox App is the easiest way to get the EAP builds and keep both your stable WebStorm version and any EAP versions up to date. Or you can download the EAP builds from our website. You can also get notified right from the IDE when a new EAP build is available: go to Preferences/Settings | Appearance & Behavior | System Settings | Updates and select “Automatically check updates for Early Access Program”.
Important! WebStorm EAP builds are not fully tested and might be unstable.
Here are some of the highlights of WebStorm 2019.3 EAP #9 (build 193.5096.13). Sketchmee download. For the full list of issues fixed in this update, see the Release Notes.
Support for the Upcoming Yarn 2 Release
A new major Yarn version is coming later this year with the Plug’n’Play feature – a completely new installation strategy for project dependencies.
In the past month, we’ve worked together with the Yarn team and put a lot of effort into making sure that all WebStorm key features work fine when using Yarn 2.
The first and most important thing we had to do was to locate and properly index a project’s dependencies (which are actually no longer located in the node_modules folder) to provide code completion and navigation. As before, WebStorm creates a JavaScript Library from these files, called Dependencies from package.json. You can disable it or configure its scope in Preferences | Languages and Frameworks | JavaScript | Libraries.
The second thing we did was to make sure that all integrated tools like linters and test runners can still be used when installed using Yarn 2.
Please note that since Yarn 2 hasn’t yet been officially released, there might still be some unexpected changes in it that might affect the way WebStorm integration works. Also please note that some tools and libraries don’t fully support Yarn 2.
If you want to give Yarn 2 a try now, you can find the installation instructions in their docs.
Better name suggestions for new variables, functions, and classes
Phpstorm Yarns
When you create a new variable, function, class, or interface, WebStorm now suggests names that were already used in the same scope but were not defined anywhere and are marked as unresolved.
For example, if you’ve decided that you want to use some new function, you can first call it and then type
function
to create it and see this name suggested. Of course, you can also press Alt-Enter on the usage and use the Create Function quick-fix.Initial support for Sass’s @use and @forward rules
WebStorm now understands Sass’s new @use and @forward rules and provides completion for the path after them. Smarter completion and resolve for imported symbols are coming soon.
Further improvements in Vue support
Now you can get code completion for filters in interpolations and
v-bind
expressions. This works for filters defined in the component or globally.If you copy some code from the script section of one Vue component and paste it into another component, WebStorm will paste the required import statements as well, the same way it works for regular JavaScript files.
Please report any issues on our issue tracker, and stay tuned for the upcoming release announcement!
The WebStorm Team
Jest is a testing platform for client-side JavaScript applications and React applications specifically. Learn more about the platform from the Jest official website.
You can run and debug tests with Jest right in PhpStorm. You can see the test results in a treeview and easily navigate to the test source from there. Test status is shown next to the test in the editor with an option to quickly run it or debug it.
Before you start
Download and install Node.js.
Installing and configuring Jest
- In the embedded Terminal (Alt+F12), type:
npm install --save-dev jest
- You can also install the jest package on the Node.js and NPM page as described in npm, pnpm, and Yarn.
Learn more from Getting Started and Configuring Jest on the Jest official website.
Running tests
With PhpStorm, you can quickly run a single Jest test right from the editor or create a run/debug configuration to execute some or all of your tests.
To run a single test from the editor
- Click or in the gutter and select Run <test_name> from the list.You can also see whether a test has passed or failed right in the editor, thanks to the test status icons and in the gutter.
To create a Jest run configuration
- Open the Run/Debug Configuration dialog (Run | Edit Configurations on the main menu), click in the left-hand pane, and select Jest from the list. The Run/Debug Configuration: Jest dialog opens.Alternatively, select a test file in the Project tool window and select Create <filename> from the context menu.
- Specify the Node.js interpreter to use. This can be a local Node.js interpreter or a Node.js on Windows Subsystem for Linux.
- Specify the location of the jest, react-scripts, react-script-ts, react-super-scripts, or react-awesome-scripts package.
- Specify the working directory of the application. By default, the Working directory field shows the project root folder. To change this predefined setting, specify the path to the desired folder or choose a previously used folder from the list.
- Optionally specify the jest.config file to use: select the relevant file from the list, or click and select it in the dialog that opens, or just type the path in the field. If the field is empty, PhpStorm looks for a package.json file with a
jest
key. The search is performed in the file system upwards from the working directory. If no appropriate package.json file is found, then a Jest default configuration is generated on the fly. - Optionally configure rerunning the tests automatically on changes in the related source files. To do that, add the
--watch
flag in the Jest options field.
To run tests via a run configuration
- Select the Jest run/debug configuration from the list on the main toolbar and click to the right of the list.
- The test server starts automatically without any steps from your side. View and analyze messages from the test server in the Run tool window.
- Monitor test execution and analyze test rest=ults in the Test Runner tab of the Run tool window, see Explore test results for details.
To rerun failed tests
- In the Test Runner tab, click on the toolbar. PhpStorm will execute all the tests that failed during the previous session.
- To rerun a specific failed test, select Run <test name> on its context menu.
See Rerunning tests for details.
Navigation
With PhpStorm, you can jump between a file and the related test file or from a test result in the Test Runner Tab to the test.
Such navigation works only if the test file follows popular naming conventions, for example, has a .test., .spec. or _spec. suffix and is located either next to the source file or in a test folder.
Phpstorm Yarn
- To jump between a test and its subject or vice versa, open the file in the editor and select Go to | Test or Go to | Test Subject from the context menu, or just press Ctrl+Shift+T.
- To jump from a test result to the test definition, click the test name in the Test Runner tab twice or select Jump to Source from the context menu. The test file opens in the editor with the cursor placed at the test definition.
- For failed tests, PhpStorm brings you to the failure line in the test from the stack trace. If the exact line is not in the stack trace, you will be taken to the test definition.
Snapshot testing
PhpStorm integration with Jest supports such a great feature as snapshot testing.
When you run a test with a
.toMatchSnapshot()
method, Jest creates a snapshot file in the __snapshots__ folder. To jump from a test to its related snapshot, click in the gutter next to the test or select the required snapshot from the context menu of the .toMatchSnapshot()
method.If a snapshot does not match the rendered application, the test fails. This indicates that either some changes in your code have caused this mismatch or the snapshot is outdated and needs to be updated.
To see what caused this mismatch, open the PhpStorm built-in Difference Viewer via the Click to see difference link in the right-hand pane of the Test Runner tab.
You can update outdated snapshots right from the Test Runner tab of the Run tool window.
- To update the snapshot for a specific test, use the Click to update snapshot link next to the test name.
- To update all outdated snapshots for the tests from a file, use the Click to update failed snapshots next to the test file name.
Debugging tests
With PhpStorm, you can quickly start debugging a single Jest test right from the editor or create a run/debug configuration to debug some or all of your tests.
- To start debugging a single test from the editor, click or in the gutter and select Debug <test_name> from the list.
- To launch test debugging via a run/debug configuration, create a Jest run/debug configuration as described above. Then select the Jest run/debug configuration from the list on the main toolbar and click to the right of the list.
In the Debug tool window that opens, proceed as usual: step through the tests, pause and resume test execution, examine the test when suspended, run JavaScript code snippets in the Console, and so on.
Monitoring code coverage
With PhpStorm, you can also monitor how much of your code is covered with Jest tests. PhpStorm displays this statistics in a dedicated Coverage tool window and marks covered and uncovered lines visually in the editor and in the Project tool window.
To run tests with coverage
- Create a Jest run/debug configuration as described above.
- Select the Jest run/debug configuration from the list on the main toolbar and click to the right of the list.Alternatively, quickly run a specific suite or a test with coverage from the editor: click or in the gutter and select Run <test_name> with Coverage from the list.
- Monitor the code coverage in the Coverage tool window. The report shows how many files were covered with tests and the percentage of covered lines in them. From the report you can jump to the file and see what lines were covered – marked green – and what lines were not covered – marked red: