[postcss-plugin] Add unit tests#1067
Merged
Merged
Conversation
d5cd765 to
95ef1af
Compare
javascripter
commented
May 18, 2025
| const postcss = require('postcss'); | ||
| const createBuilder = require('./builder'); | ||
|
|
||
| module.exports = function createPlugin() { |
Contributor
Author
There was a problem hiding this comment.
builder keeps track of files internally.
I moved the code from src/index.js to src/plugin.js and made it a factory so that each test re-creates the plugin so that no state leaks over to other tests. No other change is included in this file.
|
|
||
| async function runStylexPostcss(options = {}, inputCSS = '@stylex;') { | ||
| // Create a new instance for each test as the plugin is stateful | ||
| const stylexPostcssPlugin = createPlugin(); |
Contributor
Author
There was a problem hiding this comment.
This is where we re-create the plugin every time and reset internal state
necolas
reviewed
May 18, 2025
Comment on lines
+14
to
+20
| "jest": { | ||
| "testPathIgnorePatterns": [ | ||
| "/node_modules/", | ||
| "/__fixtures__/" | ||
| ], | ||
| "testEnvironment": "node" | ||
| }, |
Contributor
There was a problem hiding this comment.
Please move this into a jest config file (like the other packages)
| "devDependencies": { | ||
| "@babel/preset-env": "^7.26.0", | ||
| "@babel/preset-react": "^7.25.3", | ||
| "jest": "^30.0.0-alpha.7", |
Contributor
There was a problem hiding this comment.
Don't need this as the monorepo installs jest
Comment on lines
+1
to
+6
| { | ||
| "presets": [["@babel/preset-env", { "targets": { "node": "current" } }]], | ||
| "plugins": [ | ||
| ["@stylexjs/babel-plugin", { "dev": false, "runtimeInjection": false }] | ||
| ] | ||
| } |
| return result; | ||
| } | ||
|
|
||
| it('extracts CSS from StyleX files', async () => { |
Contributor
There was a problem hiding this comment.
Suggested change
| it('extracts CSS from StyleX files', async () => { | |
| test('extracts CSS from StyleX files', async () => { |
Use test for all these tests please
Comment on lines
+30
to
+31
| "@babel/preset-env": "^7.26.0", | ||
| "@babel/preset-react": "^7.25.3", |
| "@babel/preset-env": "^7.26.0", | ||
| "@babel/preset-react": "^7.25.3", | ||
| "jest": "^30.0.0-alpha.7", | ||
| "react": "^18.2.0" |
| "is-glob": "^4.0.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@babel/preset-env": "^7.26.0", |
Contributor
Author
…postcss-plugin and remove @babel/preset-env from both babel config and devDependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed / motivation ?
This PR adds tests for
@stylexjs/postcss-pluginas per #1065 (review)Linked PR/Issues
Fixes #1065 (review)
Additional Context
Checked

examples/example-nextjsstill renders correctly in this branchScreenshots, Tests, Anything Else
Pre-flight checklist
Contribution Guidelines