test(vue): Add test cases for using Options API (mixins) - #23564
Conversation
| export default defineConfig({ | ||
| plugins: [vue(), vueJsx()], | ||
| define: { |
There was a problem hiding this comment.
Bug: The __VUE_OPTIONS_API__ flag is set to the string 'false', which is truthy in JavaScript, preventing the Vue Options API from being disabled as intended.
Severity: MEDIUM
Suggested Fix
The optionsApi variable should be a boolean, not a string. Change const optionsApi = process.env.VUE_OPTIONS_API === 'false' ? 'false' : 'true'; to const optionsApi = process.env.VUE_OPTIONS_API !== 'false';. This ensures a proper boolean value is passed to Vite's define configuration.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: dev-packages/e2e-tests/test-applications/vue-3/vite.config.ts#L11-L13
Potential issue: In `vite.config.ts`, the `__VUE_OPTIONS_API__` flag is set to the
string `'false'` instead of the boolean `false`. Vite's `define` feature injects this as
a raw string literal. In JavaScript, the non-empty string `'false'` is truthy, so the
conditional check `if (__VUE_OPTIONS_API__)` in Vue's source evaluates to true. This
prevents the Options API from being disabled when intended. As a result, an E2E test
that is expected to fail (`test.fail`) when the Options API is disabled will instead
pass, masking the configuration bug.
Did we get this right? 👍 / 👎 to inform future reviews.
size-limit report 📦
|
3167826 to
a30f15c
Compare
| initSentry: async ({ app, uiSpans }, use) => { | ||
| await use(({ tracing, sdk } = {}) => { | ||
| const client = Sentry.init({ | ||
| dsn: PUBLIC_DSN, | ||
| defaultIntegrations: false, | ||
| traceLifecycle: 'static', | ||
| tracesSampleRate: 1, | ||
| app, | ||
| integrations: [Sentry.vueIntegration({ tracingOptions: { timeout: ROOT_SPAN_TIMEOUT_MS, ...tracing } })], |
There was a problem hiding this comment.
Bug: The initSentry test fixture lacks cleanup logic, causing event listeners and Sentry clients to accumulate in memory across tests, leading to a memory leak.
Severity: LOW
Suggested Fix
The initSentry fixture should be updated to include teardown logic. The client.on() method returns an unsubscribe function that should be called after the test completes. This can be implemented in the fixture after the await use() call to ensure proper cleanup between tests.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/vue/test/integration/mixinRegistration.test.ts#L83-L91
Potential issue: The `initSentry` test fixture registers a `spanEnd` event listener on a
new Sentry client for each test that uses it. However, there is no corresponding cleanup
logic to unregister the listener or close the old client after the test completes. This
results in an accumulation of old client objects and their associated event listeners in
memory throughout the test run. While each test's `uiSpans` array is isolated, this
pattern creates a memory leak and violates test isolation principles, which could lead
to performance degradation or flaky tests in a larger test suite.
Adds tests for the mixins API (we had none so far). And also adds an E2E test variant without the Options API, to demonstrate that the SDK currently does not send UI spans without it (`ui.render`, `ui.mount`, ...). Ref: #23375 Vue Options API Compile time flag: https://vuejs.org/api/compile-time-flags.html#VUE_OPTIONS_API
Adds tests for the mixins API (we had none so far).
And also adds an E2E test variant without the Options API, to demonstrate that the SDK currently does not send UI spans without it (
ui.render,ui.mount, ...).Ref: #23375
Vue Options API Compile time flag: https://vuejs.org/api/compile-time-flags.html#VUE_OPTIONS_API